From c8aeddedd4ed430f9cb6428676ebb4fa39834182 Mon Sep 17 00:00:00 2001 From: SquidDev Date: Wed, 11 Nov 2020 21:14:50 +0000 Subject: [PATCH 01/38] Auto-generate monitor models I didn't think it was worth it, and then I found myself needing to update a dozen of them. The code isn't especially pretty, but it works, so that's fine. Also fixes several issues with us using the wrong texture (closes #572). I've put together a wiki page[1] which describes each texture in a little more detail. [1] https://github.com/SquidDev-CC/CC-Tweaked/wiki/Monitor-texture-reference --- .../blockstates/monitor_advanced.json | 852 ++++++++++++++++++ .../blockstates/monitor_normal.json | 852 ++++++++++++++++++ .../models/block/monitor_advanced.json | 9 + .../models/block/monitor_advanced_d.json | 9 + .../models/block/monitor_advanced_l.json | 9 + .../models/block/monitor_advanced_ld.json | 9 + .../models/block/monitor_advanced_lr.json | 9 + .../models/block/monitor_advanced_lrd.json | 9 + .../models/block/monitor_advanced_lru.json | 9 + .../models/block/monitor_advanced_lrud.json | 9 + .../models/block/monitor_advanced_lu.json | 9 + .../models/block/monitor_advanced_lud.json | 9 + .../models/block/monitor_advanced_r.json | 9 + .../models/block/monitor_advanced_rd.json | 9 + .../models/block/monitor_advanced_ru.json | 9 + .../models/block/monitor_advanced_rud.json | 9 + .../models/block/monitor_advanced_u.json | 9 + .../models/block/monitor_advanced_ud.json | 9 + .../models/block/monitor_normal.json | 9 + .../models/block/monitor_normal_d.json | 9 + .../models/block/monitor_normal_l.json | 9 + .../models/block/monitor_normal_ld.json | 9 + .../models/block/monitor_normal_lr.json | 9 + .../models/block/monitor_normal_lrd.json | 9 + .../models/block/monitor_normal_lru.json | 9 + .../models/block/monitor_normal_lrud.json | 9 + .../models/block/monitor_normal_lu.json | 9 + .../models/block/monitor_normal_lud.json | 9 + .../models/block/monitor_normal_r.json | 9 + .../models/block/monitor_normal_rd.json | 9 + .../models/block/monitor_normal_ru.json | 9 + .../models/block/monitor_normal_rud.json | 9 + .../models/block/monitor_normal_u.json | 9 + .../models/block/monitor_normal_ud.json | 9 + .../data/BlockModelProvider.java | 109 +++ .../dan200/computercraft/data/Generators.java | 1 + .../peripheral/monitor/BlockMonitor.java | 2 +- .../peripheral/monitor/MonitorEdgeState.java | 6 + .../blockstates/monitor_advanced.json | 364 -------- .../blockstates/monitor_normal.json | 296 ------ .../models/block/monitor_advanced.json | 9 - .../models/block/monitor_advanced_d.json | 9 - .../models/block/monitor_advanced_l.json | 9 - .../models/block/monitor_advanced_ld.json | 9 - .../models/block/monitor_advanced_lr.json | 9 - .../models/block/monitor_advanced_lrd.json | 9 - .../models/block/monitor_advanced_lru.json | 9 - .../models/block/monitor_advanced_lrud.json | 9 - .../models/block/monitor_advanced_lu.json | 9 - .../models/block/monitor_advanced_lud.json | 9 - .../models/block/monitor_advanced_r.json | 9 - .../models/block/monitor_advanced_rd.json | 9 - .../models/block/monitor_advanced_ru.json | 9 - .../models/block/monitor_advanced_rud.json | 9 - .../models/block/monitor_advanced_u.json | 9 - .../models/block/monitor_advanced_ud.json | 9 - .../models/block/monitor_normal.json | 9 - .../models/block/monitor_normal_l.json | 9 - .../models/block/monitor_normal_ld.json | 9 - .../models/block/monitor_normal_lr.json | 9 - .../models/block/monitor_normal_lrd.json | 9 - .../models/block/monitor_normal_lru.json | 9 - .../models/block/monitor_normal_lrud.json | 9 - .../models/block/monitor_normal_lu.json | 9 - .../models/block/monitor_normal_lud.json | 9 - .../models/block/monitor_normal_r.json | 9 - .../models/block/monitor_normal_rd.json | 9 - .../models/block/monitor_normal_ru.json | 9 - .../models/block/monitor_normal_rud.json | 9 - .../models/block/monitor_normal_u.json | 9 - .../models/block/monitor_normal_ud.json | 9 - 71 files changed, 2109 insertions(+), 940 deletions(-) create mode 100644 src/generated/resources/assets/computercraft/blockstates/monitor_advanced.json create mode 100644 src/generated/resources/assets/computercraft/blockstates/monitor_normal.json create mode 100644 src/generated/resources/assets/computercraft/models/block/monitor_advanced.json create mode 100644 src/generated/resources/assets/computercraft/models/block/monitor_advanced_d.json create mode 100644 src/generated/resources/assets/computercraft/models/block/monitor_advanced_l.json create mode 100644 src/generated/resources/assets/computercraft/models/block/monitor_advanced_ld.json create mode 100644 src/generated/resources/assets/computercraft/models/block/monitor_advanced_lr.json create mode 100644 src/generated/resources/assets/computercraft/models/block/monitor_advanced_lrd.json create mode 100644 src/generated/resources/assets/computercraft/models/block/monitor_advanced_lru.json create mode 100644 src/generated/resources/assets/computercraft/models/block/monitor_advanced_lrud.json create mode 100644 src/generated/resources/assets/computercraft/models/block/monitor_advanced_lu.json create mode 100644 src/generated/resources/assets/computercraft/models/block/monitor_advanced_lud.json create mode 100644 src/generated/resources/assets/computercraft/models/block/monitor_advanced_r.json create mode 100644 src/generated/resources/assets/computercraft/models/block/monitor_advanced_rd.json create mode 100644 src/generated/resources/assets/computercraft/models/block/monitor_advanced_ru.json create mode 100644 src/generated/resources/assets/computercraft/models/block/monitor_advanced_rud.json create mode 100644 src/generated/resources/assets/computercraft/models/block/monitor_advanced_u.json create mode 100644 src/generated/resources/assets/computercraft/models/block/monitor_advanced_ud.json create mode 100644 src/generated/resources/assets/computercraft/models/block/monitor_normal.json create mode 100644 src/generated/resources/assets/computercraft/models/block/monitor_normal_d.json create mode 100644 src/generated/resources/assets/computercraft/models/block/monitor_normal_l.json create mode 100644 src/generated/resources/assets/computercraft/models/block/monitor_normal_ld.json create mode 100644 src/generated/resources/assets/computercraft/models/block/monitor_normal_lr.json create mode 100644 src/generated/resources/assets/computercraft/models/block/monitor_normal_lrd.json create mode 100644 src/generated/resources/assets/computercraft/models/block/monitor_normal_lru.json create mode 100644 src/generated/resources/assets/computercraft/models/block/monitor_normal_lrud.json create mode 100644 src/generated/resources/assets/computercraft/models/block/monitor_normal_lu.json create mode 100644 src/generated/resources/assets/computercraft/models/block/monitor_normal_lud.json create mode 100644 src/generated/resources/assets/computercraft/models/block/monitor_normal_r.json create mode 100644 src/generated/resources/assets/computercraft/models/block/monitor_normal_rd.json create mode 100644 src/generated/resources/assets/computercraft/models/block/monitor_normal_ru.json create mode 100644 src/generated/resources/assets/computercraft/models/block/monitor_normal_rud.json create mode 100644 src/generated/resources/assets/computercraft/models/block/monitor_normal_u.json create mode 100644 src/generated/resources/assets/computercraft/models/block/monitor_normal_ud.json create mode 100644 src/main/java/dan200/computercraft/data/BlockModelProvider.java delete mode 100644 src/main/resources/assets/computercraft/blockstates/monitor_advanced.json delete mode 100644 src/main/resources/assets/computercraft/blockstates/monitor_normal.json delete mode 100644 src/main/resources/assets/computercraft/models/block/monitor_advanced.json delete mode 100644 src/main/resources/assets/computercraft/models/block/monitor_advanced_d.json delete mode 100644 src/main/resources/assets/computercraft/models/block/monitor_advanced_l.json delete mode 100644 src/main/resources/assets/computercraft/models/block/monitor_advanced_ld.json delete mode 100644 src/main/resources/assets/computercraft/models/block/monitor_advanced_lr.json delete mode 100644 src/main/resources/assets/computercraft/models/block/monitor_advanced_lrd.json delete mode 100644 src/main/resources/assets/computercraft/models/block/monitor_advanced_lru.json delete mode 100644 src/main/resources/assets/computercraft/models/block/monitor_advanced_lrud.json delete mode 100644 src/main/resources/assets/computercraft/models/block/monitor_advanced_lu.json delete mode 100644 src/main/resources/assets/computercraft/models/block/monitor_advanced_lud.json delete mode 100644 src/main/resources/assets/computercraft/models/block/monitor_advanced_r.json delete mode 100644 src/main/resources/assets/computercraft/models/block/monitor_advanced_rd.json delete mode 100644 src/main/resources/assets/computercraft/models/block/monitor_advanced_ru.json delete mode 100644 src/main/resources/assets/computercraft/models/block/monitor_advanced_rud.json delete mode 100644 src/main/resources/assets/computercraft/models/block/monitor_advanced_u.json delete mode 100644 src/main/resources/assets/computercraft/models/block/monitor_advanced_ud.json delete mode 100644 src/main/resources/assets/computercraft/models/block/monitor_normal.json delete mode 100644 src/main/resources/assets/computercraft/models/block/monitor_normal_l.json delete mode 100644 src/main/resources/assets/computercraft/models/block/monitor_normal_ld.json delete mode 100644 src/main/resources/assets/computercraft/models/block/monitor_normal_lr.json delete mode 100644 src/main/resources/assets/computercraft/models/block/monitor_normal_lrd.json delete mode 100644 src/main/resources/assets/computercraft/models/block/monitor_normal_lru.json delete mode 100644 src/main/resources/assets/computercraft/models/block/monitor_normal_lrud.json delete mode 100644 src/main/resources/assets/computercraft/models/block/monitor_normal_lu.json delete mode 100644 src/main/resources/assets/computercraft/models/block/monitor_normal_lud.json delete mode 100644 src/main/resources/assets/computercraft/models/block/monitor_normal_r.json delete mode 100644 src/main/resources/assets/computercraft/models/block/monitor_normal_rd.json delete mode 100644 src/main/resources/assets/computercraft/models/block/monitor_normal_ru.json delete mode 100644 src/main/resources/assets/computercraft/models/block/monitor_normal_rud.json delete mode 100644 src/main/resources/assets/computercraft/models/block/monitor_normal_u.json delete mode 100644 src/main/resources/assets/computercraft/models/block/monitor_normal_ud.json diff --git a/src/generated/resources/assets/computercraft/blockstates/monitor_advanced.json b/src/generated/resources/assets/computercraft/blockstates/monitor_advanced.json new file mode 100644 index 000000000..978e3ed95 --- /dev/null +++ b/src/generated/resources/assets/computercraft/blockstates/monitor_advanced.json @@ -0,0 +1,852 @@ +{ + "variants": { + "facing=north,orientation=down,state=none": { + "model": "computercraft:block/monitor_advanced", + "x": 90 + }, + "facing=south,orientation=down,state=none": { + "model": "computercraft:block/monitor_advanced", + "x": 90, + "y": 180 + }, + "facing=west,orientation=down,state=none": { + "model": "computercraft:block/monitor_advanced", + "x": 90, + "y": 90 + }, + "facing=east,orientation=down,state=none": { + "model": "computercraft:block/monitor_advanced", + "x": 90, + "y": -90 + }, + "facing=north,orientation=up,state=none": { + "model": "computercraft:block/monitor_advanced", + "x": 270 + }, + "facing=south,orientation=up,state=none": { + "model": "computercraft:block/monitor_advanced", + "x": 270, + "y": 180 + }, + "facing=west,orientation=up,state=none": { + "model": "computercraft:block/monitor_advanced", + "x": 270, + "y": 90 + }, + "facing=east,orientation=up,state=none": { + "model": "computercraft:block/monitor_advanced", + "x": 270, + "y": -90 + }, + "facing=north,orientation=north,state=none": { + "model": "computercraft:block/monitor_advanced" + }, + "facing=south,orientation=north,state=none": { + "model": "computercraft:block/monitor_advanced", + "y": 180 + }, + "facing=west,orientation=north,state=none": { + "model": "computercraft:block/monitor_advanced", + "y": 90 + }, + "facing=east,orientation=north,state=none": { + "model": "computercraft:block/monitor_advanced", + "y": -90 + }, + "facing=north,orientation=down,state=l": { + "model": "computercraft:block/monitor_advanced_l", + "x": 90 + }, + "facing=south,orientation=down,state=l": { + "model": "computercraft:block/monitor_advanced_l", + "x": 90, + "y": 180 + }, + "facing=west,orientation=down,state=l": { + "model": "computercraft:block/monitor_advanced_l", + "x": 90, + "y": 90 + }, + "facing=east,orientation=down,state=l": { + "model": "computercraft:block/monitor_advanced_l", + "x": 90, + "y": -90 + }, + "facing=north,orientation=up,state=l": { + "model": "computercraft:block/monitor_advanced_l", + "x": 270 + }, + "facing=south,orientation=up,state=l": { + "model": "computercraft:block/monitor_advanced_l", + "x": 270, + "y": 180 + }, + "facing=west,orientation=up,state=l": { + "model": "computercraft:block/monitor_advanced_l", + "x": 270, + "y": 90 + }, + "facing=east,orientation=up,state=l": { + "model": "computercraft:block/monitor_advanced_l", + "x": 270, + "y": -90 + }, + "facing=north,orientation=north,state=l": { + "model": "computercraft:block/monitor_advanced_l" + }, + "facing=south,orientation=north,state=l": { + "model": "computercraft:block/monitor_advanced_l", + "y": 180 + }, + "facing=west,orientation=north,state=l": { + "model": "computercraft:block/monitor_advanced_l", + "y": 90 + }, + "facing=east,orientation=north,state=l": { + "model": "computercraft:block/monitor_advanced_l", + "y": -90 + }, + "facing=north,orientation=down,state=r": { + "model": "computercraft:block/monitor_advanced_r", + "x": 90 + }, + "facing=south,orientation=down,state=r": { + "model": "computercraft:block/monitor_advanced_r", + "x": 90, + "y": 180 + }, + "facing=west,orientation=down,state=r": { + "model": "computercraft:block/monitor_advanced_r", + "x": 90, + "y": 90 + }, + "facing=east,orientation=down,state=r": { + "model": "computercraft:block/monitor_advanced_r", + "x": 90, + "y": -90 + }, + "facing=north,orientation=up,state=r": { + "model": "computercraft:block/monitor_advanced_r", + "x": 270 + }, + "facing=south,orientation=up,state=r": { + "model": "computercraft:block/monitor_advanced_r", + "x": 270, + "y": 180 + }, + "facing=west,orientation=up,state=r": { + "model": "computercraft:block/monitor_advanced_r", + "x": 270, + "y": 90 + }, + "facing=east,orientation=up,state=r": { + "model": "computercraft:block/monitor_advanced_r", + "x": 270, + "y": -90 + }, + "facing=north,orientation=north,state=r": { + "model": "computercraft:block/monitor_advanced_r" + }, + "facing=south,orientation=north,state=r": { + "model": "computercraft:block/monitor_advanced_r", + "y": 180 + }, + "facing=west,orientation=north,state=r": { + "model": "computercraft:block/monitor_advanced_r", + "y": 90 + }, + "facing=east,orientation=north,state=r": { + "model": "computercraft:block/monitor_advanced_r", + "y": -90 + }, + "facing=north,orientation=down,state=lr": { + "model": "computercraft:block/monitor_advanced_lr", + "x": 90 + }, + "facing=south,orientation=down,state=lr": { + "model": "computercraft:block/monitor_advanced_lr", + "x": 90, + "y": 180 + }, + "facing=west,orientation=down,state=lr": { + "model": "computercraft:block/monitor_advanced_lr", + "x": 90, + "y": 90 + }, + "facing=east,orientation=down,state=lr": { + "model": "computercraft:block/monitor_advanced_lr", + "x": 90, + "y": -90 + }, + "facing=north,orientation=up,state=lr": { + "model": "computercraft:block/monitor_advanced_lr", + "x": 270 + }, + "facing=south,orientation=up,state=lr": { + "model": "computercraft:block/monitor_advanced_lr", + "x": 270, + "y": 180 + }, + "facing=west,orientation=up,state=lr": { + "model": "computercraft:block/monitor_advanced_lr", + "x": 270, + "y": 90 + }, + "facing=east,orientation=up,state=lr": { + "model": "computercraft:block/monitor_advanced_lr", + "x": 270, + "y": -90 + }, + "facing=north,orientation=north,state=lr": { + "model": "computercraft:block/monitor_advanced_lr" + }, + "facing=south,orientation=north,state=lr": { + "model": "computercraft:block/monitor_advanced_lr", + "y": 180 + }, + "facing=west,orientation=north,state=lr": { + "model": "computercraft:block/monitor_advanced_lr", + "y": 90 + }, + "facing=east,orientation=north,state=lr": { + "model": "computercraft:block/monitor_advanced_lr", + "y": -90 + }, + "facing=north,orientation=down,state=u": { + "model": "computercraft:block/monitor_advanced_u", + "x": 90 + }, + "facing=south,orientation=down,state=u": { + "model": "computercraft:block/monitor_advanced_u", + "x": 90, + "y": 180 + }, + "facing=west,orientation=down,state=u": { + "model": "computercraft:block/monitor_advanced_u", + "x": 90, + "y": 90 + }, + "facing=east,orientation=down,state=u": { + "model": "computercraft:block/monitor_advanced_u", + "x": 90, + "y": -90 + }, + "facing=north,orientation=up,state=u": { + "model": "computercraft:block/monitor_advanced_u", + "x": 270 + }, + "facing=south,orientation=up,state=u": { + "model": "computercraft:block/monitor_advanced_u", + "x": 270, + "y": 180 + }, + "facing=west,orientation=up,state=u": { + "model": "computercraft:block/monitor_advanced_u", + "x": 270, + "y": 90 + }, + "facing=east,orientation=up,state=u": { + "model": "computercraft:block/monitor_advanced_u", + "x": 270, + "y": -90 + }, + "facing=north,orientation=north,state=u": { + "model": "computercraft:block/monitor_advanced_u" + }, + "facing=south,orientation=north,state=u": { + "model": "computercraft:block/monitor_advanced_u", + "y": 180 + }, + "facing=west,orientation=north,state=u": { + "model": "computercraft:block/monitor_advanced_u", + "y": 90 + }, + "facing=east,orientation=north,state=u": { + "model": "computercraft:block/monitor_advanced_u", + "y": -90 + }, + "facing=north,orientation=down,state=d": { + "model": "computercraft:block/monitor_advanced_d", + "x": 90 + }, + "facing=south,orientation=down,state=d": { + "model": "computercraft:block/monitor_advanced_d", + "x": 90, + "y": 180 + }, + "facing=west,orientation=down,state=d": { + "model": "computercraft:block/monitor_advanced_d", + "x": 90, + "y": 90 + }, + "facing=east,orientation=down,state=d": { + "model": "computercraft:block/monitor_advanced_d", + "x": 90, + "y": -90 + }, + "facing=north,orientation=up,state=d": { + "model": "computercraft:block/monitor_advanced_d", + "x": 270 + }, + "facing=south,orientation=up,state=d": { + "model": "computercraft:block/monitor_advanced_d", + "x": 270, + "y": 180 + }, + "facing=west,orientation=up,state=d": { + "model": "computercraft:block/monitor_advanced_d", + "x": 270, + "y": 90 + }, + "facing=east,orientation=up,state=d": { + "model": "computercraft:block/monitor_advanced_d", + "x": 270, + "y": -90 + }, + "facing=north,orientation=north,state=d": { + "model": "computercraft:block/monitor_advanced_d" + }, + "facing=south,orientation=north,state=d": { + "model": "computercraft:block/monitor_advanced_d", + "y": 180 + }, + "facing=west,orientation=north,state=d": { + "model": "computercraft:block/monitor_advanced_d", + "y": 90 + }, + "facing=east,orientation=north,state=d": { + "model": "computercraft:block/monitor_advanced_d", + "y": -90 + }, + "facing=north,orientation=down,state=ud": { + "model": "computercraft:block/monitor_advanced_ud", + "x": 90 + }, + "facing=south,orientation=down,state=ud": { + "model": "computercraft:block/monitor_advanced_ud", + "x": 90, + "y": 180 + }, + "facing=west,orientation=down,state=ud": { + "model": "computercraft:block/monitor_advanced_ud", + "x": 90, + "y": 90 + }, + "facing=east,orientation=down,state=ud": { + "model": "computercraft:block/monitor_advanced_ud", + "x": 90, + "y": -90 + }, + "facing=north,orientation=up,state=ud": { + "model": "computercraft:block/monitor_advanced_ud", + "x": 270 + }, + "facing=south,orientation=up,state=ud": { + "model": "computercraft:block/monitor_advanced_ud", + "x": 270, + "y": 180 + }, + "facing=west,orientation=up,state=ud": { + "model": "computercraft:block/monitor_advanced_ud", + "x": 270, + "y": 90 + }, + "facing=east,orientation=up,state=ud": { + "model": "computercraft:block/monitor_advanced_ud", + "x": 270, + "y": -90 + }, + "facing=north,orientation=north,state=ud": { + "model": "computercraft:block/monitor_advanced_ud" + }, + "facing=south,orientation=north,state=ud": { + "model": "computercraft:block/monitor_advanced_ud", + "y": 180 + }, + "facing=west,orientation=north,state=ud": { + "model": "computercraft:block/monitor_advanced_ud", + "y": 90 + }, + "facing=east,orientation=north,state=ud": { + "model": "computercraft:block/monitor_advanced_ud", + "y": -90 + }, + "facing=north,orientation=down,state=rd": { + "model": "computercraft:block/monitor_advanced_rd", + "x": 90 + }, + "facing=south,orientation=down,state=rd": { + "model": "computercraft:block/monitor_advanced_rd", + "x": 90, + "y": 180 + }, + "facing=west,orientation=down,state=rd": { + "model": "computercraft:block/monitor_advanced_rd", + "x": 90, + "y": 90 + }, + "facing=east,orientation=down,state=rd": { + "model": "computercraft:block/monitor_advanced_rd", + "x": 90, + "y": -90 + }, + "facing=north,orientation=up,state=rd": { + "model": "computercraft:block/monitor_advanced_rd", + "x": 270 + }, + "facing=south,orientation=up,state=rd": { + "model": "computercraft:block/monitor_advanced_rd", + "x": 270, + "y": 180 + }, + "facing=west,orientation=up,state=rd": { + "model": "computercraft:block/monitor_advanced_rd", + "x": 270, + "y": 90 + }, + "facing=east,orientation=up,state=rd": { + "model": "computercraft:block/monitor_advanced_rd", + "x": 270, + "y": -90 + }, + "facing=north,orientation=north,state=rd": { + "model": "computercraft:block/monitor_advanced_rd" + }, + "facing=south,orientation=north,state=rd": { + "model": "computercraft:block/monitor_advanced_rd", + "y": 180 + }, + "facing=west,orientation=north,state=rd": { + "model": "computercraft:block/monitor_advanced_rd", + "y": 90 + }, + "facing=east,orientation=north,state=rd": { + "model": "computercraft:block/monitor_advanced_rd", + "y": -90 + }, + "facing=north,orientation=down,state=ld": { + "model": "computercraft:block/monitor_advanced_ld", + "x": 90 + }, + "facing=south,orientation=down,state=ld": { + "model": "computercraft:block/monitor_advanced_ld", + "x": 90, + "y": 180 + }, + "facing=west,orientation=down,state=ld": { + "model": "computercraft:block/monitor_advanced_ld", + "x": 90, + "y": 90 + }, + "facing=east,orientation=down,state=ld": { + "model": "computercraft:block/monitor_advanced_ld", + "x": 90, + "y": -90 + }, + "facing=north,orientation=up,state=ld": { + "model": "computercraft:block/monitor_advanced_ld", + "x": 270 + }, + "facing=south,orientation=up,state=ld": { + "model": "computercraft:block/monitor_advanced_ld", + "x": 270, + "y": 180 + }, + "facing=west,orientation=up,state=ld": { + "model": "computercraft:block/monitor_advanced_ld", + "x": 270, + "y": 90 + }, + "facing=east,orientation=up,state=ld": { + "model": "computercraft:block/monitor_advanced_ld", + "x": 270, + "y": -90 + }, + "facing=north,orientation=north,state=ld": { + "model": "computercraft:block/monitor_advanced_ld" + }, + "facing=south,orientation=north,state=ld": { + "model": "computercraft:block/monitor_advanced_ld", + "y": 180 + }, + "facing=west,orientation=north,state=ld": { + "model": "computercraft:block/monitor_advanced_ld", + "y": 90 + }, + "facing=east,orientation=north,state=ld": { + "model": "computercraft:block/monitor_advanced_ld", + "y": -90 + }, + "facing=north,orientation=down,state=ru": { + "model": "computercraft:block/monitor_advanced_ru", + "x": 90 + }, + "facing=south,orientation=down,state=ru": { + "model": "computercraft:block/monitor_advanced_ru", + "x": 90, + "y": 180 + }, + "facing=west,orientation=down,state=ru": { + "model": "computercraft:block/monitor_advanced_ru", + "x": 90, + "y": 90 + }, + "facing=east,orientation=down,state=ru": { + "model": "computercraft:block/monitor_advanced_ru", + "x": 90, + "y": -90 + }, + "facing=north,orientation=up,state=ru": { + "model": "computercraft:block/monitor_advanced_ru", + "x": 270 + }, + "facing=south,orientation=up,state=ru": { + "model": "computercraft:block/monitor_advanced_ru", + "x": 270, + "y": 180 + }, + "facing=west,orientation=up,state=ru": { + "model": "computercraft:block/monitor_advanced_ru", + "x": 270, + "y": 90 + }, + "facing=east,orientation=up,state=ru": { + "model": "computercraft:block/monitor_advanced_ru", + "x": 270, + "y": -90 + }, + "facing=north,orientation=north,state=ru": { + "model": "computercraft:block/monitor_advanced_ru" + }, + "facing=south,orientation=north,state=ru": { + "model": "computercraft:block/monitor_advanced_ru", + "y": 180 + }, + "facing=west,orientation=north,state=ru": { + "model": "computercraft:block/monitor_advanced_ru", + "y": 90 + }, + "facing=east,orientation=north,state=ru": { + "model": "computercraft:block/monitor_advanced_ru", + "y": -90 + }, + "facing=north,orientation=down,state=lu": { + "model": "computercraft:block/monitor_advanced_lu", + "x": 90 + }, + "facing=south,orientation=down,state=lu": { + "model": "computercraft:block/monitor_advanced_lu", + "x": 90, + "y": 180 + }, + "facing=west,orientation=down,state=lu": { + "model": "computercraft:block/monitor_advanced_lu", + "x": 90, + "y": 90 + }, + "facing=east,orientation=down,state=lu": { + "model": "computercraft:block/monitor_advanced_lu", + "x": 90, + "y": -90 + }, + "facing=north,orientation=up,state=lu": { + "model": "computercraft:block/monitor_advanced_lu", + "x": 270 + }, + "facing=south,orientation=up,state=lu": { + "model": "computercraft:block/monitor_advanced_lu", + "x": 270, + "y": 180 + }, + "facing=west,orientation=up,state=lu": { + "model": "computercraft:block/monitor_advanced_lu", + "x": 270, + "y": 90 + }, + "facing=east,orientation=up,state=lu": { + "model": "computercraft:block/monitor_advanced_lu", + "x": 270, + "y": -90 + }, + "facing=north,orientation=north,state=lu": { + "model": "computercraft:block/monitor_advanced_lu" + }, + "facing=south,orientation=north,state=lu": { + "model": "computercraft:block/monitor_advanced_lu", + "y": 180 + }, + "facing=west,orientation=north,state=lu": { + "model": "computercraft:block/monitor_advanced_lu", + "y": 90 + }, + "facing=east,orientation=north,state=lu": { + "model": "computercraft:block/monitor_advanced_lu", + "y": -90 + }, + "facing=north,orientation=down,state=lrd": { + "model": "computercraft:block/monitor_advanced_lrd", + "x": 90 + }, + "facing=south,orientation=down,state=lrd": { + "model": "computercraft:block/monitor_advanced_lrd", + "x": 90, + "y": 180 + }, + "facing=west,orientation=down,state=lrd": { + "model": "computercraft:block/monitor_advanced_lrd", + "x": 90, + "y": 90 + }, + "facing=east,orientation=down,state=lrd": { + "model": "computercraft:block/monitor_advanced_lrd", + "x": 90, + "y": -90 + }, + "facing=north,orientation=up,state=lrd": { + "model": "computercraft:block/monitor_advanced_lrd", + "x": 270 + }, + "facing=south,orientation=up,state=lrd": { + "model": "computercraft:block/monitor_advanced_lrd", + "x": 270, + "y": 180 + }, + "facing=west,orientation=up,state=lrd": { + "model": "computercraft:block/monitor_advanced_lrd", + "x": 270, + "y": 90 + }, + "facing=east,orientation=up,state=lrd": { + "model": "computercraft:block/monitor_advanced_lrd", + "x": 270, + "y": -90 + }, + "facing=north,orientation=north,state=lrd": { + "model": "computercraft:block/monitor_advanced_lrd" + }, + "facing=south,orientation=north,state=lrd": { + "model": "computercraft:block/monitor_advanced_lrd", + "y": 180 + }, + "facing=west,orientation=north,state=lrd": { + "model": "computercraft:block/monitor_advanced_lrd", + "y": 90 + }, + "facing=east,orientation=north,state=lrd": { + "model": "computercraft:block/monitor_advanced_lrd", + "y": -90 + }, + "facing=north,orientation=down,state=rud": { + "model": "computercraft:block/monitor_advanced_rud", + "x": 90 + }, + "facing=south,orientation=down,state=rud": { + "model": "computercraft:block/monitor_advanced_rud", + "x": 90, + "y": 180 + }, + "facing=west,orientation=down,state=rud": { + "model": "computercraft:block/monitor_advanced_rud", + "x": 90, + "y": 90 + }, + "facing=east,orientation=down,state=rud": { + "model": "computercraft:block/monitor_advanced_rud", + "x": 90, + "y": -90 + }, + "facing=north,orientation=up,state=rud": { + "model": "computercraft:block/monitor_advanced_rud", + "x": 270 + }, + "facing=south,orientation=up,state=rud": { + "model": "computercraft:block/monitor_advanced_rud", + "x": 270, + "y": 180 + }, + "facing=west,orientation=up,state=rud": { + "model": "computercraft:block/monitor_advanced_rud", + "x": 270, + "y": 90 + }, + "facing=east,orientation=up,state=rud": { + "model": "computercraft:block/monitor_advanced_rud", + "x": 270, + "y": -90 + }, + "facing=north,orientation=north,state=rud": { + "model": "computercraft:block/monitor_advanced_rud" + }, + "facing=south,orientation=north,state=rud": { + "model": "computercraft:block/monitor_advanced_rud", + "y": 180 + }, + "facing=west,orientation=north,state=rud": { + "model": "computercraft:block/monitor_advanced_rud", + "y": 90 + }, + "facing=east,orientation=north,state=rud": { + "model": "computercraft:block/monitor_advanced_rud", + "y": -90 + }, + "facing=north,orientation=down,state=lud": { + "model": "computercraft:block/monitor_advanced_lud", + "x": 90 + }, + "facing=south,orientation=down,state=lud": { + "model": "computercraft:block/monitor_advanced_lud", + "x": 90, + "y": 180 + }, + "facing=west,orientation=down,state=lud": { + "model": "computercraft:block/monitor_advanced_lud", + "x": 90, + "y": 90 + }, + "facing=east,orientation=down,state=lud": { + "model": "computercraft:block/monitor_advanced_lud", + "x": 90, + "y": -90 + }, + "facing=north,orientation=up,state=lud": { + "model": "computercraft:block/monitor_advanced_lud", + "x": 270 + }, + "facing=south,orientation=up,state=lud": { + "model": "computercraft:block/monitor_advanced_lud", + "x": 270, + "y": 180 + }, + "facing=west,orientation=up,state=lud": { + "model": "computercraft:block/monitor_advanced_lud", + "x": 270, + "y": 90 + }, + "facing=east,orientation=up,state=lud": { + "model": "computercraft:block/monitor_advanced_lud", + "x": 270, + "y": -90 + }, + "facing=north,orientation=north,state=lud": { + "model": "computercraft:block/monitor_advanced_lud" + }, + "facing=south,orientation=north,state=lud": { + "model": "computercraft:block/monitor_advanced_lud", + "y": 180 + }, + "facing=west,orientation=north,state=lud": { + "model": "computercraft:block/monitor_advanced_lud", + "y": 90 + }, + "facing=east,orientation=north,state=lud": { + "model": "computercraft:block/monitor_advanced_lud", + "y": -90 + }, + "facing=north,orientation=down,state=lru": { + "model": "computercraft:block/monitor_advanced_lru", + "x": 90 + }, + "facing=south,orientation=down,state=lru": { + "model": "computercraft:block/monitor_advanced_lru", + "x": 90, + "y": 180 + }, + "facing=west,orientation=down,state=lru": { + "model": "computercraft:block/monitor_advanced_lru", + "x": 90, + "y": 90 + }, + "facing=east,orientation=down,state=lru": { + "model": "computercraft:block/monitor_advanced_lru", + "x": 90, + "y": -90 + }, + "facing=north,orientation=up,state=lru": { + "model": "computercraft:block/monitor_advanced_lru", + "x": 270 + }, + "facing=south,orientation=up,state=lru": { + "model": "computercraft:block/monitor_advanced_lru", + "x": 270, + "y": 180 + }, + "facing=west,orientation=up,state=lru": { + "model": "computercraft:block/monitor_advanced_lru", + "x": 270, + "y": 90 + }, + "facing=east,orientation=up,state=lru": { + "model": "computercraft:block/monitor_advanced_lru", + "x": 270, + "y": -90 + }, + "facing=north,orientation=north,state=lru": { + "model": "computercraft:block/monitor_advanced_lru" + }, + "facing=south,orientation=north,state=lru": { + "model": "computercraft:block/monitor_advanced_lru", + "y": 180 + }, + "facing=west,orientation=north,state=lru": { + "model": "computercraft:block/monitor_advanced_lru", + "y": 90 + }, + "facing=east,orientation=north,state=lru": { + "model": "computercraft:block/monitor_advanced_lru", + "y": -90 + }, + "facing=north,orientation=down,state=lrud": { + "model": "computercraft:block/monitor_advanced_lrud", + "x": 90 + }, + "facing=south,orientation=down,state=lrud": { + "model": "computercraft:block/monitor_advanced_lrud", + "x": 90, + "y": 180 + }, + "facing=west,orientation=down,state=lrud": { + "model": "computercraft:block/monitor_advanced_lrud", + "x": 90, + "y": 90 + }, + "facing=east,orientation=down,state=lrud": { + "model": "computercraft:block/monitor_advanced_lrud", + "x": 90, + "y": -90 + }, + "facing=north,orientation=up,state=lrud": { + "model": "computercraft:block/monitor_advanced_lrud", + "x": 270 + }, + "facing=south,orientation=up,state=lrud": { + "model": "computercraft:block/monitor_advanced_lrud", + "x": 270, + "y": 180 + }, + "facing=west,orientation=up,state=lrud": { + "model": "computercraft:block/monitor_advanced_lrud", + "x": 270, + "y": 90 + }, + "facing=east,orientation=up,state=lrud": { + "model": "computercraft:block/monitor_advanced_lrud", + "x": 270, + "y": -90 + }, + "facing=north,orientation=north,state=lrud": { + "model": "computercraft:block/monitor_advanced_lrud" + }, + "facing=south,orientation=north,state=lrud": { + "model": "computercraft:block/monitor_advanced_lrud", + "y": 180 + }, + "facing=west,orientation=north,state=lrud": { + "model": "computercraft:block/monitor_advanced_lrud", + "y": 90 + }, + "facing=east,orientation=north,state=lrud": { + "model": "computercraft:block/monitor_advanced_lrud", + "y": -90 + } + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/computercraft/blockstates/monitor_normal.json b/src/generated/resources/assets/computercraft/blockstates/monitor_normal.json new file mode 100644 index 000000000..64d2d4ce9 --- /dev/null +++ b/src/generated/resources/assets/computercraft/blockstates/monitor_normal.json @@ -0,0 +1,852 @@ +{ + "variants": { + "facing=north,orientation=down,state=none": { + "model": "computercraft:block/monitor_normal", + "x": 90 + }, + "facing=south,orientation=down,state=none": { + "model": "computercraft:block/monitor_normal", + "x": 90, + "y": 180 + }, + "facing=west,orientation=down,state=none": { + "model": "computercraft:block/monitor_normal", + "x": 90, + "y": 90 + }, + "facing=east,orientation=down,state=none": { + "model": "computercraft:block/monitor_normal", + "x": 90, + "y": -90 + }, + "facing=north,orientation=up,state=none": { + "model": "computercraft:block/monitor_normal", + "x": 270 + }, + "facing=south,orientation=up,state=none": { + "model": "computercraft:block/monitor_normal", + "x": 270, + "y": 180 + }, + "facing=west,orientation=up,state=none": { + "model": "computercraft:block/monitor_normal", + "x": 270, + "y": 90 + }, + "facing=east,orientation=up,state=none": { + "model": "computercraft:block/monitor_normal", + "x": 270, + "y": -90 + }, + "facing=north,orientation=north,state=none": { + "model": "computercraft:block/monitor_normal" + }, + "facing=south,orientation=north,state=none": { + "model": "computercraft:block/monitor_normal", + "y": 180 + }, + "facing=west,orientation=north,state=none": { + "model": "computercraft:block/monitor_normal", + "y": 90 + }, + "facing=east,orientation=north,state=none": { + "model": "computercraft:block/monitor_normal", + "y": -90 + }, + "facing=north,orientation=down,state=l": { + "model": "computercraft:block/monitor_normal_l", + "x": 90 + }, + "facing=south,orientation=down,state=l": { + "model": "computercraft:block/monitor_normal_l", + "x": 90, + "y": 180 + }, + "facing=west,orientation=down,state=l": { + "model": "computercraft:block/monitor_normal_l", + "x": 90, + "y": 90 + }, + "facing=east,orientation=down,state=l": { + "model": "computercraft:block/monitor_normal_l", + "x": 90, + "y": -90 + }, + "facing=north,orientation=up,state=l": { + "model": "computercraft:block/monitor_normal_l", + "x": 270 + }, + "facing=south,orientation=up,state=l": { + "model": "computercraft:block/monitor_normal_l", + "x": 270, + "y": 180 + }, + "facing=west,orientation=up,state=l": { + "model": "computercraft:block/monitor_normal_l", + "x": 270, + "y": 90 + }, + "facing=east,orientation=up,state=l": { + "model": "computercraft:block/monitor_normal_l", + "x": 270, + "y": -90 + }, + "facing=north,orientation=north,state=l": { + "model": "computercraft:block/monitor_normal_l" + }, + "facing=south,orientation=north,state=l": { + "model": "computercraft:block/monitor_normal_l", + "y": 180 + }, + "facing=west,orientation=north,state=l": { + "model": "computercraft:block/monitor_normal_l", + "y": 90 + }, + "facing=east,orientation=north,state=l": { + "model": "computercraft:block/monitor_normal_l", + "y": -90 + }, + "facing=north,orientation=down,state=r": { + "model": "computercraft:block/monitor_normal_r", + "x": 90 + }, + "facing=south,orientation=down,state=r": { + "model": "computercraft:block/monitor_normal_r", + "x": 90, + "y": 180 + }, + "facing=west,orientation=down,state=r": { + "model": "computercraft:block/monitor_normal_r", + "x": 90, + "y": 90 + }, + "facing=east,orientation=down,state=r": { + "model": "computercraft:block/monitor_normal_r", + "x": 90, + "y": -90 + }, + "facing=north,orientation=up,state=r": { + "model": "computercraft:block/monitor_normal_r", + "x": 270 + }, + "facing=south,orientation=up,state=r": { + "model": "computercraft:block/monitor_normal_r", + "x": 270, + "y": 180 + }, + "facing=west,orientation=up,state=r": { + "model": "computercraft:block/monitor_normal_r", + "x": 270, + "y": 90 + }, + "facing=east,orientation=up,state=r": { + "model": "computercraft:block/monitor_normal_r", + "x": 270, + "y": -90 + }, + "facing=north,orientation=north,state=r": { + "model": "computercraft:block/monitor_normal_r" + }, + "facing=south,orientation=north,state=r": { + "model": "computercraft:block/monitor_normal_r", + "y": 180 + }, + "facing=west,orientation=north,state=r": { + "model": "computercraft:block/monitor_normal_r", + "y": 90 + }, + "facing=east,orientation=north,state=r": { + "model": "computercraft:block/monitor_normal_r", + "y": -90 + }, + "facing=north,orientation=down,state=lr": { + "model": "computercraft:block/monitor_normal_lr", + "x": 90 + }, + "facing=south,orientation=down,state=lr": { + "model": "computercraft:block/monitor_normal_lr", + "x": 90, + "y": 180 + }, + "facing=west,orientation=down,state=lr": { + "model": "computercraft:block/monitor_normal_lr", + "x": 90, + "y": 90 + }, + "facing=east,orientation=down,state=lr": { + "model": "computercraft:block/monitor_normal_lr", + "x": 90, + "y": -90 + }, + "facing=north,orientation=up,state=lr": { + "model": "computercraft:block/monitor_normal_lr", + "x": 270 + }, + "facing=south,orientation=up,state=lr": { + "model": "computercraft:block/monitor_normal_lr", + "x": 270, + "y": 180 + }, + "facing=west,orientation=up,state=lr": { + "model": "computercraft:block/monitor_normal_lr", + "x": 270, + "y": 90 + }, + "facing=east,orientation=up,state=lr": { + "model": "computercraft:block/monitor_normal_lr", + "x": 270, + "y": -90 + }, + "facing=north,orientation=north,state=lr": { + "model": "computercraft:block/monitor_normal_lr" + }, + "facing=south,orientation=north,state=lr": { + "model": "computercraft:block/monitor_normal_lr", + "y": 180 + }, + "facing=west,orientation=north,state=lr": { + "model": "computercraft:block/monitor_normal_lr", + "y": 90 + }, + "facing=east,orientation=north,state=lr": { + "model": "computercraft:block/monitor_normal_lr", + "y": -90 + }, + "facing=north,orientation=down,state=u": { + "model": "computercraft:block/monitor_normal_u", + "x": 90 + }, + "facing=south,orientation=down,state=u": { + "model": "computercraft:block/monitor_normal_u", + "x": 90, + "y": 180 + }, + "facing=west,orientation=down,state=u": { + "model": "computercraft:block/monitor_normal_u", + "x": 90, + "y": 90 + }, + "facing=east,orientation=down,state=u": { + "model": "computercraft:block/monitor_normal_u", + "x": 90, + "y": -90 + }, + "facing=north,orientation=up,state=u": { + "model": "computercraft:block/monitor_normal_u", + "x": 270 + }, + "facing=south,orientation=up,state=u": { + "model": "computercraft:block/monitor_normal_u", + "x": 270, + "y": 180 + }, + "facing=west,orientation=up,state=u": { + "model": "computercraft:block/monitor_normal_u", + "x": 270, + "y": 90 + }, + "facing=east,orientation=up,state=u": { + "model": "computercraft:block/monitor_normal_u", + "x": 270, + "y": -90 + }, + "facing=north,orientation=north,state=u": { + "model": "computercraft:block/monitor_normal_u" + }, + "facing=south,orientation=north,state=u": { + "model": "computercraft:block/monitor_normal_u", + "y": 180 + }, + "facing=west,orientation=north,state=u": { + "model": "computercraft:block/monitor_normal_u", + "y": 90 + }, + "facing=east,orientation=north,state=u": { + "model": "computercraft:block/monitor_normal_u", + "y": -90 + }, + "facing=north,orientation=down,state=d": { + "model": "computercraft:block/monitor_normal_d", + "x": 90 + }, + "facing=south,orientation=down,state=d": { + "model": "computercraft:block/monitor_normal_d", + "x": 90, + "y": 180 + }, + "facing=west,orientation=down,state=d": { + "model": "computercraft:block/monitor_normal_d", + "x": 90, + "y": 90 + }, + "facing=east,orientation=down,state=d": { + "model": "computercraft:block/monitor_normal_d", + "x": 90, + "y": -90 + }, + "facing=north,orientation=up,state=d": { + "model": "computercraft:block/monitor_normal_d", + "x": 270 + }, + "facing=south,orientation=up,state=d": { + "model": "computercraft:block/monitor_normal_d", + "x": 270, + "y": 180 + }, + "facing=west,orientation=up,state=d": { + "model": "computercraft:block/monitor_normal_d", + "x": 270, + "y": 90 + }, + "facing=east,orientation=up,state=d": { + "model": "computercraft:block/monitor_normal_d", + "x": 270, + "y": -90 + }, + "facing=north,orientation=north,state=d": { + "model": "computercraft:block/monitor_normal_d" + }, + "facing=south,orientation=north,state=d": { + "model": "computercraft:block/monitor_normal_d", + "y": 180 + }, + "facing=west,orientation=north,state=d": { + "model": "computercraft:block/monitor_normal_d", + "y": 90 + }, + "facing=east,orientation=north,state=d": { + "model": "computercraft:block/monitor_normal_d", + "y": -90 + }, + "facing=north,orientation=down,state=ud": { + "model": "computercraft:block/monitor_normal_ud", + "x": 90 + }, + "facing=south,orientation=down,state=ud": { + "model": "computercraft:block/monitor_normal_ud", + "x": 90, + "y": 180 + }, + "facing=west,orientation=down,state=ud": { + "model": "computercraft:block/monitor_normal_ud", + "x": 90, + "y": 90 + }, + "facing=east,orientation=down,state=ud": { + "model": "computercraft:block/monitor_normal_ud", + "x": 90, + "y": -90 + }, + "facing=north,orientation=up,state=ud": { + "model": "computercraft:block/monitor_normal_ud", + "x": 270 + }, + "facing=south,orientation=up,state=ud": { + "model": "computercraft:block/monitor_normal_ud", + "x": 270, + "y": 180 + }, + "facing=west,orientation=up,state=ud": { + "model": "computercraft:block/monitor_normal_ud", + "x": 270, + "y": 90 + }, + "facing=east,orientation=up,state=ud": { + "model": "computercraft:block/monitor_normal_ud", + "x": 270, + "y": -90 + }, + "facing=north,orientation=north,state=ud": { + "model": "computercraft:block/monitor_normal_ud" + }, + "facing=south,orientation=north,state=ud": { + "model": "computercraft:block/monitor_normal_ud", + "y": 180 + }, + "facing=west,orientation=north,state=ud": { + "model": "computercraft:block/monitor_normal_ud", + "y": 90 + }, + "facing=east,orientation=north,state=ud": { + "model": "computercraft:block/monitor_normal_ud", + "y": -90 + }, + "facing=north,orientation=down,state=rd": { + "model": "computercraft:block/monitor_normal_rd", + "x": 90 + }, + "facing=south,orientation=down,state=rd": { + "model": "computercraft:block/monitor_normal_rd", + "x": 90, + "y": 180 + }, + "facing=west,orientation=down,state=rd": { + "model": "computercraft:block/monitor_normal_rd", + "x": 90, + "y": 90 + }, + "facing=east,orientation=down,state=rd": { + "model": "computercraft:block/monitor_normal_rd", + "x": 90, + "y": -90 + }, + "facing=north,orientation=up,state=rd": { + "model": "computercraft:block/monitor_normal_rd", + "x": 270 + }, + "facing=south,orientation=up,state=rd": { + "model": "computercraft:block/monitor_normal_rd", + "x": 270, + "y": 180 + }, + "facing=west,orientation=up,state=rd": { + "model": "computercraft:block/monitor_normal_rd", + "x": 270, + "y": 90 + }, + "facing=east,orientation=up,state=rd": { + "model": "computercraft:block/monitor_normal_rd", + "x": 270, + "y": -90 + }, + "facing=north,orientation=north,state=rd": { + "model": "computercraft:block/monitor_normal_rd" + }, + "facing=south,orientation=north,state=rd": { + "model": "computercraft:block/monitor_normal_rd", + "y": 180 + }, + "facing=west,orientation=north,state=rd": { + "model": "computercraft:block/monitor_normal_rd", + "y": 90 + }, + "facing=east,orientation=north,state=rd": { + "model": "computercraft:block/monitor_normal_rd", + "y": -90 + }, + "facing=north,orientation=down,state=ld": { + "model": "computercraft:block/monitor_normal_ld", + "x": 90 + }, + "facing=south,orientation=down,state=ld": { + "model": "computercraft:block/monitor_normal_ld", + "x": 90, + "y": 180 + }, + "facing=west,orientation=down,state=ld": { + "model": "computercraft:block/monitor_normal_ld", + "x": 90, + "y": 90 + }, + "facing=east,orientation=down,state=ld": { + "model": "computercraft:block/monitor_normal_ld", + "x": 90, + "y": -90 + }, + "facing=north,orientation=up,state=ld": { + "model": "computercraft:block/monitor_normal_ld", + "x": 270 + }, + "facing=south,orientation=up,state=ld": { + "model": "computercraft:block/monitor_normal_ld", + "x": 270, + "y": 180 + }, + "facing=west,orientation=up,state=ld": { + "model": "computercraft:block/monitor_normal_ld", + "x": 270, + "y": 90 + }, + "facing=east,orientation=up,state=ld": { + "model": "computercraft:block/monitor_normal_ld", + "x": 270, + "y": -90 + }, + "facing=north,orientation=north,state=ld": { + "model": "computercraft:block/monitor_normal_ld" + }, + "facing=south,orientation=north,state=ld": { + "model": "computercraft:block/monitor_normal_ld", + "y": 180 + }, + "facing=west,orientation=north,state=ld": { + "model": "computercraft:block/monitor_normal_ld", + "y": 90 + }, + "facing=east,orientation=north,state=ld": { + "model": "computercraft:block/monitor_normal_ld", + "y": -90 + }, + "facing=north,orientation=down,state=ru": { + "model": "computercraft:block/monitor_normal_ru", + "x": 90 + }, + "facing=south,orientation=down,state=ru": { + "model": "computercraft:block/monitor_normal_ru", + "x": 90, + "y": 180 + }, + "facing=west,orientation=down,state=ru": { + "model": "computercraft:block/monitor_normal_ru", + "x": 90, + "y": 90 + }, + "facing=east,orientation=down,state=ru": { + "model": "computercraft:block/monitor_normal_ru", + "x": 90, + "y": -90 + }, + "facing=north,orientation=up,state=ru": { + "model": "computercraft:block/monitor_normal_ru", + "x": 270 + }, + "facing=south,orientation=up,state=ru": { + "model": "computercraft:block/monitor_normal_ru", + "x": 270, + "y": 180 + }, + "facing=west,orientation=up,state=ru": { + "model": "computercraft:block/monitor_normal_ru", + "x": 270, + "y": 90 + }, + "facing=east,orientation=up,state=ru": { + "model": "computercraft:block/monitor_normal_ru", + "x": 270, + "y": -90 + }, + "facing=north,orientation=north,state=ru": { + "model": "computercraft:block/monitor_normal_ru" + }, + "facing=south,orientation=north,state=ru": { + "model": "computercraft:block/monitor_normal_ru", + "y": 180 + }, + "facing=west,orientation=north,state=ru": { + "model": "computercraft:block/monitor_normal_ru", + "y": 90 + }, + "facing=east,orientation=north,state=ru": { + "model": "computercraft:block/monitor_normal_ru", + "y": -90 + }, + "facing=north,orientation=down,state=lu": { + "model": "computercraft:block/monitor_normal_lu", + "x": 90 + }, + "facing=south,orientation=down,state=lu": { + "model": "computercraft:block/monitor_normal_lu", + "x": 90, + "y": 180 + }, + "facing=west,orientation=down,state=lu": { + "model": "computercraft:block/monitor_normal_lu", + "x": 90, + "y": 90 + }, + "facing=east,orientation=down,state=lu": { + "model": "computercraft:block/monitor_normal_lu", + "x": 90, + "y": -90 + }, + "facing=north,orientation=up,state=lu": { + "model": "computercraft:block/monitor_normal_lu", + "x": 270 + }, + "facing=south,orientation=up,state=lu": { + "model": "computercraft:block/monitor_normal_lu", + "x": 270, + "y": 180 + }, + "facing=west,orientation=up,state=lu": { + "model": "computercraft:block/monitor_normal_lu", + "x": 270, + "y": 90 + }, + "facing=east,orientation=up,state=lu": { + "model": "computercraft:block/monitor_normal_lu", + "x": 270, + "y": -90 + }, + "facing=north,orientation=north,state=lu": { + "model": "computercraft:block/monitor_normal_lu" + }, + "facing=south,orientation=north,state=lu": { + "model": "computercraft:block/monitor_normal_lu", + "y": 180 + }, + "facing=west,orientation=north,state=lu": { + "model": "computercraft:block/monitor_normal_lu", + "y": 90 + }, + "facing=east,orientation=north,state=lu": { + "model": "computercraft:block/monitor_normal_lu", + "y": -90 + }, + "facing=north,orientation=down,state=lrd": { + "model": "computercraft:block/monitor_normal_lrd", + "x": 90 + }, + "facing=south,orientation=down,state=lrd": { + "model": "computercraft:block/monitor_normal_lrd", + "x": 90, + "y": 180 + }, + "facing=west,orientation=down,state=lrd": { + "model": "computercraft:block/monitor_normal_lrd", + "x": 90, + "y": 90 + }, + "facing=east,orientation=down,state=lrd": { + "model": "computercraft:block/monitor_normal_lrd", + "x": 90, + "y": -90 + }, + "facing=north,orientation=up,state=lrd": { + "model": "computercraft:block/monitor_normal_lrd", + "x": 270 + }, + "facing=south,orientation=up,state=lrd": { + "model": "computercraft:block/monitor_normal_lrd", + "x": 270, + "y": 180 + }, + "facing=west,orientation=up,state=lrd": { + "model": "computercraft:block/monitor_normal_lrd", + "x": 270, + "y": 90 + }, + "facing=east,orientation=up,state=lrd": { + "model": "computercraft:block/monitor_normal_lrd", + "x": 270, + "y": -90 + }, + "facing=north,orientation=north,state=lrd": { + "model": "computercraft:block/monitor_normal_lrd" + }, + "facing=south,orientation=north,state=lrd": { + "model": "computercraft:block/monitor_normal_lrd", + "y": 180 + }, + "facing=west,orientation=north,state=lrd": { + "model": "computercraft:block/monitor_normal_lrd", + "y": 90 + }, + "facing=east,orientation=north,state=lrd": { + "model": "computercraft:block/monitor_normal_lrd", + "y": -90 + }, + "facing=north,orientation=down,state=rud": { + "model": "computercraft:block/monitor_normal_rud", + "x": 90 + }, + "facing=south,orientation=down,state=rud": { + "model": "computercraft:block/monitor_normal_rud", + "x": 90, + "y": 180 + }, + "facing=west,orientation=down,state=rud": { + "model": "computercraft:block/monitor_normal_rud", + "x": 90, + "y": 90 + }, + "facing=east,orientation=down,state=rud": { + "model": "computercraft:block/monitor_normal_rud", + "x": 90, + "y": -90 + }, + "facing=north,orientation=up,state=rud": { + "model": "computercraft:block/monitor_normal_rud", + "x": 270 + }, + "facing=south,orientation=up,state=rud": { + "model": "computercraft:block/monitor_normal_rud", + "x": 270, + "y": 180 + }, + "facing=west,orientation=up,state=rud": { + "model": "computercraft:block/monitor_normal_rud", + "x": 270, + "y": 90 + }, + "facing=east,orientation=up,state=rud": { + "model": "computercraft:block/monitor_normal_rud", + "x": 270, + "y": -90 + }, + "facing=north,orientation=north,state=rud": { + "model": "computercraft:block/monitor_normal_rud" + }, + "facing=south,orientation=north,state=rud": { + "model": "computercraft:block/monitor_normal_rud", + "y": 180 + }, + "facing=west,orientation=north,state=rud": { + "model": "computercraft:block/monitor_normal_rud", + "y": 90 + }, + "facing=east,orientation=north,state=rud": { + "model": "computercraft:block/monitor_normal_rud", + "y": -90 + }, + "facing=north,orientation=down,state=lud": { + "model": "computercraft:block/monitor_normal_lud", + "x": 90 + }, + "facing=south,orientation=down,state=lud": { + "model": "computercraft:block/monitor_normal_lud", + "x": 90, + "y": 180 + }, + "facing=west,orientation=down,state=lud": { + "model": "computercraft:block/monitor_normal_lud", + "x": 90, + "y": 90 + }, + "facing=east,orientation=down,state=lud": { + "model": "computercraft:block/monitor_normal_lud", + "x": 90, + "y": -90 + }, + "facing=north,orientation=up,state=lud": { + "model": "computercraft:block/monitor_normal_lud", + "x": 270 + }, + "facing=south,orientation=up,state=lud": { + "model": "computercraft:block/monitor_normal_lud", + "x": 270, + "y": 180 + }, + "facing=west,orientation=up,state=lud": { + "model": "computercraft:block/monitor_normal_lud", + "x": 270, + "y": 90 + }, + "facing=east,orientation=up,state=lud": { + "model": "computercraft:block/monitor_normal_lud", + "x": 270, + "y": -90 + }, + "facing=north,orientation=north,state=lud": { + "model": "computercraft:block/monitor_normal_lud" + }, + "facing=south,orientation=north,state=lud": { + "model": "computercraft:block/monitor_normal_lud", + "y": 180 + }, + "facing=west,orientation=north,state=lud": { + "model": "computercraft:block/monitor_normal_lud", + "y": 90 + }, + "facing=east,orientation=north,state=lud": { + "model": "computercraft:block/monitor_normal_lud", + "y": -90 + }, + "facing=north,orientation=down,state=lru": { + "model": "computercraft:block/monitor_normal_lru", + "x": 90 + }, + "facing=south,orientation=down,state=lru": { + "model": "computercraft:block/monitor_normal_lru", + "x": 90, + "y": 180 + }, + "facing=west,orientation=down,state=lru": { + "model": "computercraft:block/monitor_normal_lru", + "x": 90, + "y": 90 + }, + "facing=east,orientation=down,state=lru": { + "model": "computercraft:block/monitor_normal_lru", + "x": 90, + "y": -90 + }, + "facing=north,orientation=up,state=lru": { + "model": "computercraft:block/monitor_normal_lru", + "x": 270 + }, + "facing=south,orientation=up,state=lru": { + "model": "computercraft:block/monitor_normal_lru", + "x": 270, + "y": 180 + }, + "facing=west,orientation=up,state=lru": { + "model": "computercraft:block/monitor_normal_lru", + "x": 270, + "y": 90 + }, + "facing=east,orientation=up,state=lru": { + "model": "computercraft:block/monitor_normal_lru", + "x": 270, + "y": -90 + }, + "facing=north,orientation=north,state=lru": { + "model": "computercraft:block/monitor_normal_lru" + }, + "facing=south,orientation=north,state=lru": { + "model": "computercraft:block/monitor_normal_lru", + "y": 180 + }, + "facing=west,orientation=north,state=lru": { + "model": "computercraft:block/monitor_normal_lru", + "y": 90 + }, + "facing=east,orientation=north,state=lru": { + "model": "computercraft:block/monitor_normal_lru", + "y": -90 + }, + "facing=north,orientation=down,state=lrud": { + "model": "computercraft:block/monitor_normal_lrud", + "x": 90 + }, + "facing=south,orientation=down,state=lrud": { + "model": "computercraft:block/monitor_normal_lrud", + "x": 90, + "y": 180 + }, + "facing=west,orientation=down,state=lrud": { + "model": "computercraft:block/monitor_normal_lrud", + "x": 90, + "y": 90 + }, + "facing=east,orientation=down,state=lrud": { + "model": "computercraft:block/monitor_normal_lrud", + "x": 90, + "y": -90 + }, + "facing=north,orientation=up,state=lrud": { + "model": "computercraft:block/monitor_normal_lrud", + "x": 270 + }, + "facing=south,orientation=up,state=lrud": { + "model": "computercraft:block/monitor_normal_lrud", + "x": 270, + "y": 180 + }, + "facing=west,orientation=up,state=lrud": { + "model": "computercraft:block/monitor_normal_lrud", + "x": 270, + "y": 90 + }, + "facing=east,orientation=up,state=lrud": { + "model": "computercraft:block/monitor_normal_lrud", + "x": 270, + "y": -90 + }, + "facing=north,orientation=north,state=lrud": { + "model": "computercraft:block/monitor_normal_lrud" + }, + "facing=south,orientation=north,state=lrud": { + "model": "computercraft:block/monitor_normal_lrud", + "y": 180 + }, + "facing=west,orientation=north,state=lrud": { + "model": "computercraft:block/monitor_normal_lrud", + "y": 90 + }, + "facing=east,orientation=north,state=lrud": { + "model": "computercraft:block/monitor_normal_lrud", + "y": -90 + } + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/computercraft/models/block/monitor_advanced.json b/src/generated/resources/assets/computercraft/models/block/monitor_advanced.json new file mode 100644 index 000000000..a13f34e05 --- /dev/null +++ b/src/generated/resources/assets/computercraft/models/block/monitor_advanced.json @@ -0,0 +1,9 @@ +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:block/monitor_advanced_16", + "side": "computercraft:block/monitor_advanced_4", + "top": "computercraft:block/monitor_advanced_0", + "back": "computercraft:block/monitor_advanced_32" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/computercraft/models/block/monitor_advanced_d.json b/src/generated/resources/assets/computercraft/models/block/monitor_advanced_d.json new file mode 100644 index 000000000..ff39d102c --- /dev/null +++ b/src/generated/resources/assets/computercraft/models/block/monitor_advanced_d.json @@ -0,0 +1,9 @@ +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:block/monitor_advanced_20", + "side": "computercraft:block/monitor_advanced_7", + "top": "computercraft:block/monitor_advanced_0", + "back": "computercraft:block/monitor_advanced_36" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/computercraft/models/block/monitor_advanced_l.json b/src/generated/resources/assets/computercraft/models/block/monitor_advanced_l.json new file mode 100644 index 000000000..3bfb91292 --- /dev/null +++ b/src/generated/resources/assets/computercraft/models/block/monitor_advanced_l.json @@ -0,0 +1,9 @@ +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:block/monitor_advanced_19", + "side": "computercraft:block/monitor_advanced_4", + "top": "computercraft:block/monitor_advanced_1", + "back": "computercraft:block/monitor_advanced_33" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/computercraft/models/block/monitor_advanced_ld.json b/src/generated/resources/assets/computercraft/models/block/monitor_advanced_ld.json new file mode 100644 index 000000000..25269670d --- /dev/null +++ b/src/generated/resources/assets/computercraft/models/block/monitor_advanced_ld.json @@ -0,0 +1,9 @@ +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:block/monitor_advanced_31", + "side": "computercraft:block/monitor_advanced_7", + "top": "computercraft:block/monitor_advanced_1", + "back": "computercraft:block/monitor_advanced_45" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/computercraft/models/block/monitor_advanced_lr.json b/src/generated/resources/assets/computercraft/models/block/monitor_advanced_lr.json new file mode 100644 index 000000000..d94c3a5cf --- /dev/null +++ b/src/generated/resources/assets/computercraft/models/block/monitor_advanced_lr.json @@ -0,0 +1,9 @@ +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:block/monitor_advanced_18", + "side": "computercraft:block/monitor_advanced_4", + "top": "computercraft:block/monitor_advanced_2", + "back": "computercraft:block/monitor_advanced_34" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/computercraft/models/block/monitor_advanced_lrd.json b/src/generated/resources/assets/computercraft/models/block/monitor_advanced_lrd.json new file mode 100644 index 000000000..0de1d3268 --- /dev/null +++ b/src/generated/resources/assets/computercraft/models/block/monitor_advanced_lrd.json @@ -0,0 +1,9 @@ +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:block/monitor_advanced_30", + "side": "computercraft:block/monitor_advanced_7", + "top": "computercraft:block/monitor_advanced_2", + "back": "computercraft:block/monitor_advanced_46" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/computercraft/models/block/monitor_advanced_lru.json b/src/generated/resources/assets/computercraft/models/block/monitor_advanced_lru.json new file mode 100644 index 000000000..a28abc853 --- /dev/null +++ b/src/generated/resources/assets/computercraft/models/block/monitor_advanced_lru.json @@ -0,0 +1,9 @@ +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:block/monitor_advanced_24", + "side": "computercraft:block/monitor_advanced_5", + "top": "computercraft:block/monitor_advanced_2", + "back": "computercraft:block/monitor_advanced_40" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/computercraft/models/block/monitor_advanced_lrud.json b/src/generated/resources/assets/computercraft/models/block/monitor_advanced_lrud.json new file mode 100644 index 000000000..9759d442e --- /dev/null +++ b/src/generated/resources/assets/computercraft/models/block/monitor_advanced_lrud.json @@ -0,0 +1,9 @@ +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:block/monitor_advanced_27", + "side": "computercraft:block/monitor_advanced_6", + "top": "computercraft:block/monitor_advanced_2", + "back": "computercraft:block/monitor_advanced_43" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/computercraft/models/block/monitor_advanced_lu.json b/src/generated/resources/assets/computercraft/models/block/monitor_advanced_lu.json new file mode 100644 index 000000000..038626c68 --- /dev/null +++ b/src/generated/resources/assets/computercraft/models/block/monitor_advanced_lu.json @@ -0,0 +1,9 @@ +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:block/monitor_advanced_25", + "side": "computercraft:block/monitor_advanced_5", + "top": "computercraft:block/monitor_advanced_1", + "back": "computercraft:block/monitor_advanced_39" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/computercraft/models/block/monitor_advanced_lud.json b/src/generated/resources/assets/computercraft/models/block/monitor_advanced_lud.json new file mode 100644 index 000000000..38e9374aa --- /dev/null +++ b/src/generated/resources/assets/computercraft/models/block/monitor_advanced_lud.json @@ -0,0 +1,9 @@ +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:block/monitor_advanced_28", + "side": "computercraft:block/monitor_advanced_6", + "top": "computercraft:block/monitor_advanced_1", + "back": "computercraft:block/monitor_advanced_42" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/computercraft/models/block/monitor_advanced_r.json b/src/generated/resources/assets/computercraft/models/block/monitor_advanced_r.json new file mode 100644 index 000000000..555aab92c --- /dev/null +++ b/src/generated/resources/assets/computercraft/models/block/monitor_advanced_r.json @@ -0,0 +1,9 @@ +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:block/monitor_advanced_17", + "side": "computercraft:block/monitor_advanced_4", + "top": "computercraft:block/monitor_advanced_3", + "back": "computercraft:block/monitor_advanced_35" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/computercraft/models/block/monitor_advanced_rd.json b/src/generated/resources/assets/computercraft/models/block/monitor_advanced_rd.json new file mode 100644 index 000000000..22e0195b7 --- /dev/null +++ b/src/generated/resources/assets/computercraft/models/block/monitor_advanced_rd.json @@ -0,0 +1,9 @@ +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:block/monitor_advanced_29", + "side": "computercraft:block/monitor_advanced_7", + "top": "computercraft:block/monitor_advanced_3", + "back": "computercraft:block/monitor_advanced_47" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/computercraft/models/block/monitor_advanced_ru.json b/src/generated/resources/assets/computercraft/models/block/monitor_advanced_ru.json new file mode 100644 index 000000000..6a503312a --- /dev/null +++ b/src/generated/resources/assets/computercraft/models/block/monitor_advanced_ru.json @@ -0,0 +1,9 @@ +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:block/monitor_advanced_23", + "side": "computercraft:block/monitor_advanced_5", + "top": "computercraft:block/monitor_advanced_3", + "back": "computercraft:block/monitor_advanced_41" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/computercraft/models/block/monitor_advanced_rud.json b/src/generated/resources/assets/computercraft/models/block/monitor_advanced_rud.json new file mode 100644 index 000000000..70cd94b68 --- /dev/null +++ b/src/generated/resources/assets/computercraft/models/block/monitor_advanced_rud.json @@ -0,0 +1,9 @@ +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:block/monitor_advanced_26", + "side": "computercraft:block/monitor_advanced_6", + "top": "computercraft:block/monitor_advanced_3", + "back": "computercraft:block/monitor_advanced_44" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/computercraft/models/block/monitor_advanced_u.json b/src/generated/resources/assets/computercraft/models/block/monitor_advanced_u.json new file mode 100644 index 000000000..8c2271ce7 --- /dev/null +++ b/src/generated/resources/assets/computercraft/models/block/monitor_advanced_u.json @@ -0,0 +1,9 @@ +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:block/monitor_advanced_22", + "side": "computercraft:block/monitor_advanced_5", + "top": "computercraft:block/monitor_advanced_0", + "back": "computercraft:block/monitor_advanced_38" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/computercraft/models/block/monitor_advanced_ud.json b/src/generated/resources/assets/computercraft/models/block/monitor_advanced_ud.json new file mode 100644 index 000000000..481c8402d --- /dev/null +++ b/src/generated/resources/assets/computercraft/models/block/monitor_advanced_ud.json @@ -0,0 +1,9 @@ +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:block/monitor_advanced_21", + "side": "computercraft:block/monitor_advanced_6", + "top": "computercraft:block/monitor_advanced_0", + "back": "computercraft:block/monitor_advanced_37" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/computercraft/models/block/monitor_normal.json b/src/generated/resources/assets/computercraft/models/block/monitor_normal.json new file mode 100644 index 000000000..b08678497 --- /dev/null +++ b/src/generated/resources/assets/computercraft/models/block/monitor_normal.json @@ -0,0 +1,9 @@ +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:block/monitor_normal_16", + "side": "computercraft:block/monitor_normal_4", + "top": "computercraft:block/monitor_normal_0", + "back": "computercraft:block/monitor_normal_32" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/computercraft/models/block/monitor_normal_d.json b/src/generated/resources/assets/computercraft/models/block/monitor_normal_d.json new file mode 100644 index 000000000..3d6137782 --- /dev/null +++ b/src/generated/resources/assets/computercraft/models/block/monitor_normal_d.json @@ -0,0 +1,9 @@ +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:block/monitor_normal_20", + "side": "computercraft:block/monitor_normal_7", + "top": "computercraft:block/monitor_normal_0", + "back": "computercraft:block/monitor_normal_36" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/computercraft/models/block/monitor_normal_l.json b/src/generated/resources/assets/computercraft/models/block/monitor_normal_l.json new file mode 100644 index 000000000..3f863819a --- /dev/null +++ b/src/generated/resources/assets/computercraft/models/block/monitor_normal_l.json @@ -0,0 +1,9 @@ +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:block/monitor_normal_19", + "side": "computercraft:block/monitor_normal_4", + "top": "computercraft:block/monitor_normal_1", + "back": "computercraft:block/monitor_normal_33" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/computercraft/models/block/monitor_normal_ld.json b/src/generated/resources/assets/computercraft/models/block/monitor_normal_ld.json new file mode 100644 index 000000000..860b84d7d --- /dev/null +++ b/src/generated/resources/assets/computercraft/models/block/monitor_normal_ld.json @@ -0,0 +1,9 @@ +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:block/monitor_normal_31", + "side": "computercraft:block/monitor_normal_7", + "top": "computercraft:block/monitor_normal_1", + "back": "computercraft:block/monitor_normal_45" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/computercraft/models/block/monitor_normal_lr.json b/src/generated/resources/assets/computercraft/models/block/monitor_normal_lr.json new file mode 100644 index 000000000..c69bab42d --- /dev/null +++ b/src/generated/resources/assets/computercraft/models/block/monitor_normal_lr.json @@ -0,0 +1,9 @@ +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:block/monitor_normal_18", + "side": "computercraft:block/monitor_normal_4", + "top": "computercraft:block/monitor_normal_2", + "back": "computercraft:block/monitor_normal_34" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/computercraft/models/block/monitor_normal_lrd.json b/src/generated/resources/assets/computercraft/models/block/monitor_normal_lrd.json new file mode 100644 index 000000000..3dd8543a7 --- /dev/null +++ b/src/generated/resources/assets/computercraft/models/block/monitor_normal_lrd.json @@ -0,0 +1,9 @@ +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:block/monitor_normal_30", + "side": "computercraft:block/monitor_normal_7", + "top": "computercraft:block/monitor_normal_2", + "back": "computercraft:block/monitor_normal_46" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/computercraft/models/block/monitor_normal_lru.json b/src/generated/resources/assets/computercraft/models/block/monitor_normal_lru.json new file mode 100644 index 000000000..c0fe995ee --- /dev/null +++ b/src/generated/resources/assets/computercraft/models/block/monitor_normal_lru.json @@ -0,0 +1,9 @@ +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:block/monitor_normal_24", + "side": "computercraft:block/monitor_normal_5", + "top": "computercraft:block/monitor_normal_2", + "back": "computercraft:block/monitor_normal_40" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/computercraft/models/block/monitor_normal_lrud.json b/src/generated/resources/assets/computercraft/models/block/monitor_normal_lrud.json new file mode 100644 index 000000000..61545472f --- /dev/null +++ b/src/generated/resources/assets/computercraft/models/block/monitor_normal_lrud.json @@ -0,0 +1,9 @@ +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:block/monitor_normal_27", + "side": "computercraft:block/monitor_normal_6", + "top": "computercraft:block/monitor_normal_2", + "back": "computercraft:block/monitor_normal_43" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/computercraft/models/block/monitor_normal_lu.json b/src/generated/resources/assets/computercraft/models/block/monitor_normal_lu.json new file mode 100644 index 000000000..5572eb3bc --- /dev/null +++ b/src/generated/resources/assets/computercraft/models/block/monitor_normal_lu.json @@ -0,0 +1,9 @@ +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:block/monitor_normal_25", + "side": "computercraft:block/monitor_normal_5", + "top": "computercraft:block/monitor_normal_1", + "back": "computercraft:block/monitor_normal_39" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/computercraft/models/block/monitor_normal_lud.json b/src/generated/resources/assets/computercraft/models/block/monitor_normal_lud.json new file mode 100644 index 000000000..ba56cd1cd --- /dev/null +++ b/src/generated/resources/assets/computercraft/models/block/monitor_normal_lud.json @@ -0,0 +1,9 @@ +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:block/monitor_normal_28", + "side": "computercraft:block/monitor_normal_6", + "top": "computercraft:block/monitor_normal_1", + "back": "computercraft:block/monitor_normal_42" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/computercraft/models/block/monitor_normal_r.json b/src/generated/resources/assets/computercraft/models/block/monitor_normal_r.json new file mode 100644 index 000000000..bcbb7ef76 --- /dev/null +++ b/src/generated/resources/assets/computercraft/models/block/monitor_normal_r.json @@ -0,0 +1,9 @@ +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:block/monitor_normal_17", + "side": "computercraft:block/monitor_normal_4", + "top": "computercraft:block/monitor_normal_3", + "back": "computercraft:block/monitor_normal_35" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/computercraft/models/block/monitor_normal_rd.json b/src/generated/resources/assets/computercraft/models/block/monitor_normal_rd.json new file mode 100644 index 000000000..469f486c0 --- /dev/null +++ b/src/generated/resources/assets/computercraft/models/block/monitor_normal_rd.json @@ -0,0 +1,9 @@ +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:block/monitor_normal_29", + "side": "computercraft:block/monitor_normal_7", + "top": "computercraft:block/monitor_normal_3", + "back": "computercraft:block/monitor_normal_47" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/computercraft/models/block/monitor_normal_ru.json b/src/generated/resources/assets/computercraft/models/block/monitor_normal_ru.json new file mode 100644 index 000000000..ca937ffa3 --- /dev/null +++ b/src/generated/resources/assets/computercraft/models/block/monitor_normal_ru.json @@ -0,0 +1,9 @@ +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:block/monitor_normal_23", + "side": "computercraft:block/monitor_normal_5", + "top": "computercraft:block/monitor_normal_3", + "back": "computercraft:block/monitor_normal_41" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/computercraft/models/block/monitor_normal_rud.json b/src/generated/resources/assets/computercraft/models/block/monitor_normal_rud.json new file mode 100644 index 000000000..21fb19602 --- /dev/null +++ b/src/generated/resources/assets/computercraft/models/block/monitor_normal_rud.json @@ -0,0 +1,9 @@ +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:block/monitor_normal_26", + "side": "computercraft:block/monitor_normal_6", + "top": "computercraft:block/monitor_normal_3", + "back": "computercraft:block/monitor_normal_44" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/computercraft/models/block/monitor_normal_u.json b/src/generated/resources/assets/computercraft/models/block/monitor_normal_u.json new file mode 100644 index 000000000..a93b45be8 --- /dev/null +++ b/src/generated/resources/assets/computercraft/models/block/monitor_normal_u.json @@ -0,0 +1,9 @@ +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:block/monitor_normal_22", + "side": "computercraft:block/monitor_normal_5", + "top": "computercraft:block/monitor_normal_0", + "back": "computercraft:block/monitor_normal_38" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/computercraft/models/block/monitor_normal_ud.json b/src/generated/resources/assets/computercraft/models/block/monitor_normal_ud.json new file mode 100644 index 000000000..ff10350c8 --- /dev/null +++ b/src/generated/resources/assets/computercraft/models/block/monitor_normal_ud.json @@ -0,0 +1,9 @@ +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:block/monitor_normal_21", + "side": "computercraft:block/monitor_normal_6", + "top": "computercraft:block/monitor_normal_0", + "back": "computercraft:block/monitor_normal_37" + } +} \ No newline at end of file diff --git a/src/main/java/dan200/computercraft/data/BlockModelProvider.java b/src/main/java/dan200/computercraft/data/BlockModelProvider.java new file mode 100644 index 000000000..0ab5c92b8 --- /dev/null +++ b/src/main/java/dan200/computercraft/data/BlockModelProvider.java @@ -0,0 +1,109 @@ +/* + * This file is part of ComputerCraft - http://www.computercraft.info + * Copyright Daniel Ratcliffe, 2011-2020. Do not distribute without permission. + * Send enquiries to dratcliffe@gmail.com + */ + +package dan200.computercraft.data; + +import dan200.computercraft.ComputerCraft; +import dan200.computercraft.shared.Registry; +import dan200.computercraft.shared.peripheral.monitor.BlockMonitor; +import dan200.computercraft.shared.peripheral.monitor.MonitorEdgeState; +import net.minecraft.block.Block; +import net.minecraft.data.DataGenerator; +import net.minecraft.util.Direction; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.model.generators.*; + +import javax.annotation.Nonnull; + +public class BlockModelProvider extends BlockStateProvider +{ + private final ModelFile root; + + public BlockModelProvider( DataGenerator generator, ExistingFileHelper existingFileHelper ) + { + super( generator, ComputerCraft.MOD_ID, existingFileHelper ); + root = models().getExistingFile( new ResourceLocation( ComputerCraft.MOD_ID, "block/monitor_base" ) ); + } + + @Nonnull + @Override + public String getName() + { + return "Block states and models"; + } + + @Override + protected void registerStatesAndModels() + { + registerMonitors( Registry.ModBlocks.MONITOR_NORMAL.get() ); + registerMonitors( Registry.ModBlocks.MONITOR_ADVANCED.get() ); + } + + private void registerMonitors( Block block ) + { + String name = block.getRegistryName().getPath(); + registerMonitorModel( name, "", 16, 4, 0, 32 ); + registerMonitorModel( name, "_d", 20, 7, 0, 36 ); + registerMonitorModel( name, "_l", 19, 4, 1, 33 ); + registerMonitorModel( name, "_ld", 31, 7, 1, 45 ); + registerMonitorModel( name, "_lr", 18, 4, 2, 34 ); + registerMonitorModel( name, "_lrd", 30, 7, 2, 46 ); + registerMonitorModel( name, "_lru", 24, 5, 2, 40 ); + registerMonitorModel( name, "_lrud", 27, 6, 2, 43 ); + registerMonitorModel( name, "_lu", 25, 5, 1, 39 ); + registerMonitorModel( name, "_lud", 28, 6, 1, 42 ); + registerMonitorModel( name, "_r", 17, 4, 3, 35 ); + registerMonitorModel( name, "_rd", 29, 7, 3, 47 ); + registerMonitorModel( name, "_ru", 23, 5, 3, 41 ); + registerMonitorModel( name, "_rud", 26, 6, 3, 44 ); + registerMonitorModel( name, "_u", 22, 5, 0, 38 ); + registerMonitorModel( name, "_ud", 21, 6, 0, 37 ); + + VariantBlockStateBuilder builder = getVariantBuilder( block ); + for( MonitorEdgeState edge : BlockMonitor.STATE.getAllowedValues() ) + { + String suffix = edge == MonitorEdgeState.NONE ? "" : "_" + edge.getName(); + ResourceLocation modelName = new ResourceLocation( ComputerCraft.MOD_ID, "block/" + name + suffix ); + ModelFile model = models().getBuilder( modelName.toString() ); + + for( Direction facing : BlockMonitor.FACING.getAllowedValues() ) + { + for( Direction orientation : BlockMonitor.ORIENTATION.getAllowedValues() ) + { + builder.partialState() + .with( BlockMonitor.STATE, edge ) + .with( BlockMonitor.FACING, facing ) + .with( BlockMonitor.ORIENTATION, orientation ) + .addModels( new ConfiguredModel( model, toXAngle( orientation ), 180 - (int) facing.getHorizontalAngle(), false ) ); + } + } + } + } + + private void registerMonitorModel( String prefix, String corners, int front, int side, int top, int back ) + { + String texturePrefix = ComputerCraft.MOD_ID + ":block/" + prefix + "_"; + models().getBuilder( prefix + corners ) + .parent( root ) + .texture( "front", texturePrefix + front ) + .texture( "side", texturePrefix + side ) + .texture( "top", texturePrefix + top ) + .texture( "back", texturePrefix + back ); + } + + private int toXAngle( Direction direction ) + { + switch( direction ) + { + default: + return 0; + case UP: + return 270; + case DOWN: + return 90; + } + } +} diff --git a/src/main/java/dan200/computercraft/data/Generators.java b/src/main/java/dan200/computercraft/data/Generators.java index 69ef83b78..8e8f931f1 100644 --- a/src/main/java/dan200/computercraft/data/Generators.java +++ b/src/main/java/dan200/computercraft/data/Generators.java @@ -24,5 +24,6 @@ public class Generators generator.addProvider( new Recipes( generator ) ); generator.addProvider( new LootTables( generator ) ); generator.addProvider( new Tags( generator ) ); + generator.addProvider( new BlockModelProvider( generator, event.getExistingFileHelper() ) ); } } diff --git a/src/main/java/dan200/computercraft/shared/peripheral/monitor/BlockMonitor.java b/src/main/java/dan200/computercraft/shared/peripheral/monitor/BlockMonitor.java index a6df660e4..345741c59 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/monitor/BlockMonitor.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/monitor/BlockMonitor.java @@ -32,7 +32,7 @@ public class BlockMonitor extends BlockGeneric public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING; - static final EnumProperty STATE = EnumProperty.create( "state", MonitorEdgeState.class ); + public static final EnumProperty STATE = EnumProperty.create( "state", MonitorEdgeState.class ); public BlockMonitor( Properties settings, RegistryObject> type ) { diff --git a/src/main/java/dan200/computercraft/shared/peripheral/monitor/MonitorEdgeState.java b/src/main/java/dan200/computercraft/shared/peripheral/monitor/MonitorEdgeState.java index 0ada54c82..ffc7b22df 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/monitor/MonitorEdgeState.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/monitor/MonitorEdgeState.java @@ -57,6 +57,12 @@ public enum MonitorEdgeState implements IStringSerializable return BY_FLAG[(up ? UP : 0) | (down ? DOWN : 0) | (left ? LEFT : 0) | (right ? RIGHT : 0)]; } + @Override + public String toString() + { + return getName(); + } + @Nonnull @Override public String getName() diff --git a/src/main/resources/assets/computercraft/blockstates/monitor_advanced.json b/src/main/resources/assets/computercraft/blockstates/monitor_advanced.json deleted file mode 100644 index b55870f67..000000000 --- a/src/main/resources/assets/computercraft/blockstates/monitor_advanced.json +++ /dev/null @@ -1,364 +0,0 @@ -{ - "variants": { - "facing=north,orientation=north,state=none": { "model": "computercraft:block/monitor_advanced" }, - "facing=south,orientation=north,state=none": { "model": "computercraft:block/monitor_advanced", "y": 180 }, - "facing=west,orientation=north,state=none": { "model": "computercraft:block/monitor_advanced", "y": 270 }, - "facing=east,orientation=north,state=none": { "model": "computercraft:block/monitor_advanced", "y": 90 }, - "facing=north,orientation=north,state=r": { "model": "computercraft:block/monitor_advanced_r" }, - "facing=south,orientation=north,state=r": { "model": "computercraft:block/monitor_advanced_r", "y": 180 }, - "facing=west,orientation=north,state=r": { "model": "computercraft:block/monitor_advanced_r", "y": 270 }, - "facing=east,orientation=north,state=r": { "model": "computercraft:block/monitor_advanced_r", "y": 90 }, - "facing=north,orientation=north,state=lr": { "model": "computercraft:block/monitor_advanced_lr" }, - "facing=south,orientation=north,state=lr": { "model": "computercraft:block/monitor_advanced_lr", "y": 180 }, - "facing=west,orientation=north,state=lr": { "model": "computercraft:block/monitor_advanced_lr", "y": 270 }, - "facing=east,orientation=north,state=lr": { "model": "computercraft:block/monitor_advanced_lr", "y": 90 }, - "facing=north,orientation=north,state=l": { "model": "computercraft:block/monitor_advanced_l" }, - "facing=south,orientation=north,state=l": { "model": "computercraft:block/monitor_advanced_l", "y": 180 }, - "facing=west,orientation=north,state=l": { "model": "computercraft:block/monitor_advanced_l", "y": 270 }, - "facing=east,orientation=north,state=l": { "model": "computercraft:block/monitor_advanced_l", "y": 90 }, - "facing=north,orientation=north,state=d": { "model": "computercraft:block/monitor_advanced_d" }, - "facing=south,orientation=north,state=d": { "model": "computercraft:block/monitor_advanced_d", "y": 180 }, - "facing=west,orientation=north,state=d": { "model": "computercraft:block/monitor_advanced_d", "y": 270 }, - "facing=east,orientation=north,state=d": { "model": "computercraft:block/monitor_advanced_d", "y": 90 }, - "facing=north,orientation=north,state=ud": { "model": "computercraft:block/monitor_advanced_ud" }, - "facing=south,orientation=north,state=ud": { "model": "computercraft:block/monitor_advanced_ud", "y": 180 }, - "facing=west,orientation=north,state=ud": { "model": "computercraft:block/monitor_advanced_ud", "y": 270 }, - "facing=east,orientation=north,state=ud": { "model": "computercraft:block/monitor_advanced_ud", "y": 90 }, - "facing=north,orientation=north,state=u": { "model": "computercraft:block/monitor_advanced_u" }, - "facing=south,orientation=north,state=u": { "model": "computercraft:block/monitor_advanced_u", "y": 180 }, - "facing=west,orientation=north,state=u": { "model": "computercraft:block/monitor_advanced_u", "y": 270 }, - "facing=east,orientation=north,state=u": { "model": "computercraft:block/monitor_advanced_u", "y": 90 }, - "facing=north,orientation=north,state=rd": { "model": "computercraft:block/monitor_advanced_rd" }, - "facing=south,orientation=north,state=rd": { "model": "computercraft:block/monitor_advanced_rd", "y": 180 }, - "facing=west,orientation=north,state=rd": { "model": "computercraft:block/monitor_advanced_rd", "y": 270 }, - "facing=east,orientation=north,state=rd": { "model": "computercraft:block/monitor_advanced_rd", "y": 90 }, - "facing=north,orientation=north,state=lrd": { "model": "computercraft:block/monitor_advanced_lrd" }, - "facing=south,orientation=north,state=lrd": { "model": "computercraft:block/monitor_advanced_lrd", "y": 180 }, - "facing=west,orientation=north,state=lrd": { "model": "computercraft:block/monitor_advanced_lrd", "y": 270 }, - "facing=east,orientation=north,state=lrd": { "model": "computercraft:block/monitor_advanced_lrd", "y": 90 }, - "facing=north,orientation=north,state=ld": { "model": "computercraft:block/monitor_advanced_ld" }, - "facing=south,orientation=north,state=ld": { "model": "computercraft:block/monitor_advanced_ld", "y": 180 }, - "facing=west,orientation=north,state=ld": { "model": "computercraft:block/monitor_advanced_ld", "y": 270 }, - "facing=east,orientation=north,state=ld": { "model": "computercraft:block/monitor_advanced_ld", "y": 90 }, - "facing=north,orientation=north,state=rud": { "model": "computercraft:block/monitor_advanced_rud" }, - "facing=south,orientation=north,state=rud": { "model": "computercraft:block/monitor_advanced_rud", "y": 180 }, - "facing=west,orientation=north,state=rud": { "model": "computercraft:block/monitor_advanced_rud", "y": 270 }, - "facing=east,orientation=north,state=rud": { "model": "computercraft:block/monitor_advanced_rud", "y": 90 }, - "facing=north,orientation=north,state=lrud": { "model": "computercraft:block/monitor_advanced_lrud" }, - "facing=south,orientation=north,state=lrud": { "model": "computercraft:block/monitor_advanced_lrud", "y": 180 }, - "facing=west,orientation=north,state=lrud": { "model": "computercraft:block/monitor_advanced_lrud", "y": 270 }, - "facing=east,orientation=north,state=lrud": { "model": "computercraft:block/monitor_advanced_lrud", "y": 90 }, - "facing=north,orientation=north,state=lud": { "model": "computercraft:block/monitor_advanced_lud" }, - "facing=south,orientation=north,state=lud": { "model": "computercraft:block/monitor_advanced_lud", "y": 180 }, - "facing=west,orientation=north,state=lud": { "model": "computercraft:block/monitor_advanced_lud", "y": 270 }, - "facing=east,orientation=north,state=lud": { "model": "computercraft:block/monitor_advanced_lud", "y": 90 }, - "facing=north,orientation=north,state=ru": { "model": "computercraft:block/monitor_advanced_ru" }, - "facing=south,orientation=north,state=ru": { "model": "computercraft:block/monitor_advanced_ru", "y": 180 }, - "facing=west,orientation=north,state=ru": { "model": "computercraft:block/monitor_advanced_ru", "y": 270 }, - "facing=east,orientation=north,state=ru": { "model": "computercraft:block/monitor_advanced_ru", "y": 90 }, - "facing=north,orientation=north,state=lru": { "model": "computercraft:block/monitor_advanced_lru" }, - "facing=south,orientation=north,state=lru": { "model": "computercraft:block/monitor_advanced_lru", "y": 180 }, - "facing=west,orientation=north,state=lru": { "model": "computercraft:block/monitor_advanced_lru", "y": 270 }, - "facing=east,orientation=north,state=lru": { "model": "computercraft:block/monitor_advanced_lru", "y": 90 }, - "facing=north,orientation=north,state=lu": { "model": "computercraft:block/monitor_advanced_lu" }, - "facing=south,orientation=north,state=lu": { "model": "computercraft:block/monitor_advanced_lu", "y": 180 }, - "facing=west,orientation=north,state=lu": { "model": "computercraft:block/monitor_advanced_lu", "y": 270 }, - "facing=east,orientation=north,state=lu": { "model": "computercraft:block/monitor_advanced_lu", "y": 90 }, - - "facing=north,orientation=up,state=none": { "model": "computercraft:block/monitor_advanced", "x": 270 }, - "facing=south,orientation=up,state=none": { - "model": "computercraft:block/monitor_advanced", "y": 180, "x": 270 - }, - "facing=west,orientation=up,state=none": { - "model": "computercraft:block/monitor_advanced", "y": 270, "x": 270 - }, - "facing=east,orientation=up,state=none": { "model": "computercraft:block/monitor_advanced", "y": 90, "x": 270 }, - "facing=north,orientation=up,state=r": { "model": "computercraft:block/monitor_advanced_r", "x": 270 }, - "facing=south,orientation=up,state=r": { - "model": "computercraft:block/monitor_advanced_r", "y": 180, "x": 270 - }, - "facing=west,orientation=up,state=r": { "model": "computercraft:block/monitor_advanced_r", "y": 270, "x": 270 }, - "facing=east,orientation=up,state=r": { "model": "computercraft:block/monitor_advanced_r", "y": 90, "x": 270 }, - "facing=north,orientation=up,state=lr": { "model": "computercraft:block/monitor_advanced_lr", "x": 270 }, - "facing=south,orientation=up,state=lr": { - "model": "computercraft:block/monitor_advanced_lr", "y": 180, "x": 270 - }, - "facing=west,orientation=up,state=lr": { - "model": "computercraft:block/monitor_advanced_lr", "y": 270, "x": 270 - }, - "facing=east,orientation=up,state=lr": { - "model": "computercraft:block/monitor_advanced_lr", "y": 90, "x": 270 - }, - "facing=north,orientation=up,state=l": { "model": "computercraft:block/monitor_advanced_l", "x": 270 }, - "facing=south,orientation=up,state=l": { - "model": "computercraft:block/monitor_advanced_l", "y": 180, "x": 270 - }, - "facing=west,orientation=up,state=l": { "model": "computercraft:block/monitor_advanced_l", "y": 270, "x": 270 }, - "facing=east,orientation=up,state=l": { "model": "computercraft:block/monitor_advanced_l", "y": 90, "x": 270 }, - "facing=north,orientation=up,state=d": { "model": "computercraft:block/monitor_advanced_d", "x": 270 }, - "facing=south,orientation=up,state=d": { - "model": "computercraft:block/monitor_advanced_d", "y": 180, "x": 270 - }, - "facing=west,orientation=up,state=d": { "model": "computercraft:block/monitor_advanced_d", "y": 270, "x": 270 }, - "facing=east,orientation=up,state=d": { "model": "computercraft:block/monitor_advanced_d", "y": 90, "x": 270 }, - "facing=north,orientation=up,state=ud": { "model": "computercraft:block/monitor_advanced_ud", "x": 270 }, - "facing=south,orientation=up,state=ud": { - "model": "computercraft:block/monitor_advanced_ud", "y": 180, "x": 270 - }, - "facing=west,orientation=up,state=ud": { - "model": "computercraft:block/monitor_advanced_ud", "y": 270, "x": 270 - }, - "facing=east,orientation=up,state=ud": { - "model": "computercraft:block/monitor_advanced_ud", "y": 90, "x": 270 - }, - "facing=north,orientation=up,state=u": { "model": "computercraft:block/monitor_advanced_u", "x": 270 }, - "facing=south,orientation=up,state=u": { - "model": "computercraft:block/monitor_advanced_u", "y": 180, "x": 270 - }, - "facing=west,orientation=up,state=u": { "model": "computercraft:block/monitor_advanced_u", "y": 270, "x": 270 }, - "facing=east,orientation=up,state=u": { "model": "computercraft:block/monitor_advanced_u", "y": 90, "x": 270 }, - "facing=north,orientation=up,state=rd": { "model": "computercraft:block/monitor_advanced_rd", "x": 270 }, - "facing=south,orientation=up,state=rd": { - "model": "computercraft:block/monitor_advanced_rd", "y": 180, "x": 270 - }, - "facing=west,orientation=up,state=rd": { - "model": "computercraft:block/monitor_advanced_rd", "y": 270, "x": 270 - }, - "facing=east,orientation=up,state=rd": { - "model": "computercraft:block/monitor_advanced_rd", "y": 90, "x": 270 - }, - "facing=north,orientation=up,state=lrd": { "model": "computercraft:block/monitor_advanced_lrd", "x": 270 }, - "facing=south,orientation=up,state=lrd": { - "model": "computercraft:block/monitor_advanced_lrd", "y": 180, "x": 270 - }, - "facing=west,orientation=up,state=lrd": { - "model": "computercraft:block/monitor_advanced_lrd", "y": 270, "x": 270 - }, - "facing=east,orientation=up,state=lrd": { - "model": "computercraft:block/monitor_advanced_lrd", "y": 90, "x": 270 - }, - "facing=north,orientation=up,state=ld": { "model": "computercraft:block/monitor_advanced_ld", "x": 270 }, - "facing=south,orientation=up,state=ld": { - "model": "computercraft:block/monitor_advanced_ld", "y": 180, "x": 270 - }, - "facing=west,orientation=up,state=ld": { - "model": "computercraft:block/monitor_advanced_ld", "y": 270, "x": 270 - }, - "facing=east,orientation=up,state=ld": { - "model": "computercraft:block/monitor_advanced_ld", "y": 90, "x": 270 - }, - "facing=north,orientation=up,state=rud": { "model": "computercraft:block/monitor_advanced_rud", "x": 270 }, - "facing=south,orientation=up,state=rud": { - "model": "computercraft:block/monitor_advanced_rud", "y": 180, "x": 270 - }, - "facing=west,orientation=up,state=rud": { - "model": "computercraft:block/monitor_advanced_rud", "y": 270, "x": 270 - }, - "facing=east,orientation=up,state=rud": { - "model": "computercraft:block/monitor_advanced_rud", "y": 90, "x": 270 - }, - "facing=north,orientation=up,state=lrud": { "model": "computercraft:block/monitor_advanced_lrud", "x": 270 }, - "facing=south,orientation=up,state=lrud": { - "model": "computercraft:block/monitor_advanced_lrud", "y": 180, "x": 270 - }, - "facing=west,orientation=up,state=lrud": { - "model": "computercraft:block/monitor_advanced_lrud", "y": 270, "x": 270 - }, - "facing=east,orientation=up,state=lrud": { - "model": "computercraft:block/monitor_advanced_lrud", "y": 90, "x": 270 - }, - "facing=north,orientation=up,state=lud": { "model": "computercraft:block/monitor_advanced_lud", "x": 270 }, - "facing=south,orientation=up,state=lud": { - "model": "computercraft:block/monitor_advanced_lud", "y": 180, "x": 270 - }, - "facing=west,orientation=up,state=lud": { - "model": "computercraft:block/monitor_advanced_lud", "y": 270, "x": 270 - }, - "facing=east,orientation=up,state=lud": { - "model": "computercraft:block/monitor_advanced_lud", "y": 90, "x": 270 - }, - "facing=north,orientation=up,state=ru": { "model": "computercraft:block/monitor_advanced_ru", "x": 270 }, - "facing=south,orientation=up,state=ru": { - "model": "computercraft:block/monitor_advanced_ru", "y": 180, "x": 270 - }, - "facing=west,orientation=up,state=ru": { - "model": "computercraft:block/monitor_advanced_ru", "y": 270, "x": 270 - }, - "facing=east,orientation=up,state=ru": { - "model": "computercraft:block/monitor_advanced_ru", "y": 90, "x": 270 - }, - "facing=north,orientation=up,state=lru": { "model": "computercraft:block/monitor_advanced_lru", "x": 270 }, - "facing=south,orientation=up,state=lru": { - "model": "computercraft:block/monitor_advanced_lru", "y": 180, "x": 270 - }, - "facing=west,orientation=up,state=lru": { - "model": "computercraft:block/monitor_advanced_lru", "y": 270, "x": 270 - }, - "facing=east,orientation=up,state=lru": { - "model": "computercraft:block/monitor_advanced_lru", "y": 90, "x": 270 - }, - "facing=north,orientation=up,state=lu": { "model": "computercraft:block/monitor_advanced_lu", "x": 270 }, - "facing=south,orientation=up,state=lu": { - "model": "computercraft:block/monitor_advanced_lu", "y": 180, "x": 270 - }, - "facing=west,orientation=up,state=lu": { - "model": "computercraft:block/monitor_advanced_lu", "y": 270, "x": 270 - }, - "facing=east,orientation=up,state=lu": { - "model": "computercraft:block/monitor_advanced_lu", "y": 90, "x": 270 - }, - - "facing=north,orientation=down,state=none": { "model": "computercraft:block/monitor_advanced", "x": 90 }, - "facing=south,orientation=down,state=none": { - "model": "computercraft:block/monitor_advanced", "y": 180, "x": 90 - }, - "facing=west,orientation=down,state=none": { - "model": "computercraft:block/monitor_advanced", "y": 270, "x": 90 - }, - "facing=east,orientation=down,state=none": { - "model": "computercraft:block/monitor_advanced", "y": 90, "x": 90 - }, - "facing=north,orientation=down,state=r": { "model": "computercraft:block/monitor_advanced_r", "x": 90 }, - "facing=south,orientation=down,state=r": { - "model": "computercraft:block/monitor_advanced_r", "y": 180, "x": 90 - }, - "facing=west,orientation=down,state=r": { - "model": "computercraft:block/monitor_advanced_r", "y": 270, "x": 90 - }, - "facing=east,orientation=down,state=r": { "model": "computercraft:block/monitor_advanced_r", "y": 90, "x": 90 }, - "facing=north,orientation=down,state=lr": { "model": "computercraft:block/monitor_advanced_lr", "x": 90 }, - "facing=south,orientation=down,state=lr": { - "model": "computercraft:block/monitor_advanced_lr", "y": 180, "x": 90 - }, - "facing=west,orientation=down,state=lr": { - "model": "computercraft:block/monitor_advanced_lr", "y": 270, "x": 90 - }, - "facing=east,orientation=down,state=lr": { - "model": "computercraft:block/monitor_advanced_lr", "y": 90, "x": 90 - }, - "facing=north,orientation=down,state=l": { "model": "computercraft:block/monitor_advanced_l", "x": 90 }, - "facing=south,orientation=down,state=l": { - "model": "computercraft:block/monitor_advanced_l", "y": 180, "x": 90 - }, - "facing=west,orientation=down,state=l": { - "model": "computercraft:block/monitor_advanced_l", "y": 270, "x": 90 - }, - "facing=east,orientation=down,state=l": { "model": "computercraft:block/monitor_advanced_l", "y": 90, "x": 90 }, - "facing=north,orientation=down,state=d": { "model": "computercraft:block/monitor_advanced_d", "x": 90 }, - "facing=south,orientation=down,state=d": { - "model": "computercraft:block/monitor_advanced_d", "y": 180, "x": 90 - }, - "facing=west,orientation=down,state=d": { - "model": "computercraft:block/monitor_advanced_d", "y": 270, "x": 90 - }, - "facing=east,orientation=down,state=d": { "model": "computercraft:block/monitor_advanced_d", "y": 90, "x": 90 }, - "facing=north,orientation=down,state=ud": { "model": "computercraft:block/monitor_advanced_ud", "x": 90 }, - "facing=south,orientation=down,state=ud": { - "model": "computercraft:block/monitor_advanced_ud", "y": 180, "x": 90 - }, - "facing=west,orientation=down,state=ud": { - "model": "computercraft:block/monitor_advanced_ud", "y": 270, "x": 90 - }, - "facing=east,orientation=down,state=ud": { - "model": "computercraft:block/monitor_advanced_ud", "y": 90, "x": 90 - }, - "facing=north,orientation=down,state=u": { "model": "computercraft:block/monitor_advanced_u", "x": 90 }, - "facing=south,orientation=down,state=u": { - "model": "computercraft:block/monitor_advanced_u", "y": 180, "x": 90 - }, - "facing=west,orientation=down,state=u": { - "model": "computercraft:block/monitor_advanced_u", "y": 270, "x": 90 - }, - "facing=east,orientation=down,state=u": { "model": "computercraft:block/monitor_advanced_u", "y": 90, "x": 90 }, - "facing=north,orientation=down,state=rd": { "model": "computercraft:block/monitor_advanced_rd", "x": 90 }, - "facing=south,orientation=down,state=rd": { - "model": "computercraft:block/monitor_advanced_rd", "y": 180, "x": 90 - }, - "facing=west,orientation=down,state=rd": { - "model": "computercraft:block/monitor_advanced_rd", "y": 270, "x": 90 - }, - "facing=east,orientation=down,state=rd": { - "model": "computercraft:block/monitor_advanced_rd", "y": 90, "x": 90 - }, - "facing=north,orientation=down,state=lrd": { "model": "computercraft:block/monitor_advanced_lrd", "x": 90 }, - "facing=south,orientation=down,state=lrd": { - "model": "computercraft:block/monitor_advanced_lrd", "y": 180, "x": 90 - }, - "facing=west,orientation=down,state=lrd": { - "model": "computercraft:block/monitor_advanced_lrd", "y": 270, "x": 90 - }, - "facing=east,orientation=down,state=lrd": { - "model": "computercraft:block/monitor_advanced_lrd", "y": 90, "x": 90 - }, - "facing=north,orientation=down,state=ld": { "model": "computercraft:block/monitor_advanced_ld", "x": 90 }, - "facing=south,orientation=down,state=ld": { - "model": "computercraft:block/monitor_advanced_ld", "y": 180, "x": 90 - }, - "facing=west,orientation=down,state=ld": { - "model": "computercraft:block/monitor_advanced_ld", "y": 270, "x": 90 - }, - "facing=east,orientation=down,state=ld": { - "model": "computercraft:block/monitor_advanced_ld", "y": 90, "x": 90 - }, - "facing=north,orientation=down,state=rud": { "model": "computercraft:block/monitor_advanced_rud", "x": 90 }, - "facing=south,orientation=down,state=rud": { - "model": "computercraft:block/monitor_advanced_rud", "y": 180, "x": 90 - }, - "facing=west,orientation=down,state=rud": { - "model": "computercraft:block/monitor_advanced_rud", "y": 270, "x": 90 - }, - "facing=east,orientation=down,state=rud": { - "model": "computercraft:block/monitor_advanced_rud", "y": 90, "x": 90 - }, - "facing=north,orientation=down,state=lrud": { "model": "computercraft:block/monitor_advanced_lrud", "x": 90 }, - "facing=south,orientation=down,state=lrud": { - "model": "computercraft:block/monitor_advanced_lrud", "y": 180, "x": 90 - }, - "facing=west,orientation=down,state=lrud": { - "model": "computercraft:block/monitor_advanced_lrud", "y": 270, "x": 90 - }, - "facing=east,orientation=down,state=lrud": { - "model": "computercraft:block/monitor_advanced_lrud", "y": 90, "x": 90 - }, - "facing=north,orientation=down,state=lud": { "model": "computercraft:block/monitor_advanced_lud", "x": 90 }, - "facing=south,orientation=down,state=lud": { - "model": "computercraft:block/monitor_advanced_lud", "y": 180, "x": 90 - }, - "facing=west,orientation=down,state=lud": { - "model": "computercraft:block/monitor_advanced_lud", "y": 270, "x": 90 - }, - "facing=east,orientation=down,state=lud": { - "model": "computercraft:block/monitor_advanced_lud", "y": 90, "x": 90 - }, - "facing=north,orientation=down,state=ru": { "model": "computercraft:block/monitor_advanced_ru", "x": 90 }, - "facing=south,orientation=down,state=ru": { - "model": "computercraft:block/monitor_advanced_ru", "y": 180, "x": 90 - }, - "facing=west,orientation=down,state=ru": { - "model": "computercraft:block/monitor_advanced_ru", "y": 270, "x": 90 - }, - "facing=east,orientation=down,state=ru": { - "model": "computercraft:block/monitor_advanced_ru", "y": 90, "x": 90 - }, - "facing=north,orientation=down,state=lru": { "model": "computercraft:block/monitor_advanced_lru", "x": 90 }, - "facing=south,orientation=down,state=lru": { - "model": "computercraft:block/monitor_advanced_lru", "y": 180, "x": 90 - }, - "facing=west,orientation=down,state=lru": { - "model": "computercraft:block/monitor_advanced_lru", "y": 270, "x": 90 - }, - "facing=east,orientation=down,state=lru": { - "model": "computercraft:block/monitor_advanced_lru", "y": 90, "x": 90 - }, - "facing=north,orientation=down,state=lu": { "model": "computercraft:block/monitor_advanced_lu", "x": 90 }, - "facing=south,orientation=down,state=lu": { - "model": "computercraft:block/monitor_advanced_lu", "y": 180, "x": 90 - }, - "facing=west,orientation=down,state=lu": { - "model": "computercraft:block/monitor_advanced_lu", "y": 270, "x": 90 - }, - "facing=east,orientation=down,state=lu": { - "model": "computercraft:block/monitor_advanced_lu", "y": 90, "x": 90 - } - } -} diff --git a/src/main/resources/assets/computercraft/blockstates/monitor_normal.json b/src/main/resources/assets/computercraft/blockstates/monitor_normal.json deleted file mode 100644 index b14a45a21..000000000 --- a/src/main/resources/assets/computercraft/blockstates/monitor_normal.json +++ /dev/null @@ -1,296 +0,0 @@ -{ - "variants": { - "facing=north,orientation=north,state=none": { "model": "computercraft:block/monitor_normal" }, - "facing=south,orientation=north,state=none": { "model": "computercraft:block/monitor_normal", "y": 180 }, - "facing=west,orientation=north,state=none": { "model": "computercraft:block/monitor_normal", "y": 270 }, - "facing=east,orientation=north,state=none": { "model": "computercraft:block/monitor_normal", "y": 90 }, - "facing=north,orientation=north,state=r": { "model": "computercraft:block/monitor_normal_r" }, - "facing=south,orientation=north,state=r": { "model": "computercraft:block/monitor_normal_r", "y": 180 }, - "facing=west,orientation=north,state=r": { "model": "computercraft:block/monitor_normal_r", "y": 270 }, - "facing=east,orientation=north,state=r": { "model": "computercraft:block/monitor_normal_r", "y": 90 }, - "facing=north,orientation=north,state=lr": { "model": "computercraft:block/monitor_normal_lr" }, - "facing=south,orientation=north,state=lr": { "model": "computercraft:block/monitor_normal_lr", "y": 180 }, - "facing=west,orientation=north,state=lr": { "model": "computercraft:block/monitor_normal_lr", "y": 270 }, - "facing=east,orientation=north,state=lr": { "model": "computercraft:block/monitor_normal_lr", "y": 90 }, - "facing=north,orientation=north,state=l": { "model": "computercraft:block/monitor_normal_l" }, - "facing=south,orientation=north,state=l": { "model": "computercraft:block/monitor_normal_l", "y": 180 }, - "facing=west,orientation=north,state=l": { "model": "computercraft:block/monitor_normal_l", "y": 270 }, - "facing=east,orientation=north,state=l": { "model": "computercraft:block/monitor_normal_l", "y": 90 }, - "facing=north,orientation=north,state=d": { "model": "computercraft:block/monitor_normal_d" }, - "facing=south,orientation=north,state=d": { "model": "computercraft:block/monitor_normal_d", "y": 180 }, - "facing=west,orientation=north,state=d": { "model": "computercraft:block/monitor_normal_d", "y": 270 }, - "facing=east,orientation=north,state=d": { "model": "computercraft:block/monitor_normal_d", "y": 90 }, - "facing=north,orientation=north,state=ud": { "model": "computercraft:block/monitor_normal_ud" }, - "facing=south,orientation=north,state=ud": { "model": "computercraft:block/monitor_normal_ud", "y": 180 }, - "facing=west,orientation=north,state=ud": { "model": "computercraft:block/monitor_normal_ud", "y": 270 }, - "facing=east,orientation=north,state=ud": { "model": "computercraft:block/monitor_normal_ud", "y": 90 }, - "facing=north,orientation=north,state=u": { "model": "computercraft:block/monitor_normal_u" }, - "facing=south,orientation=north,state=u": { "model": "computercraft:block/monitor_normal_u", "y": 180 }, - "facing=west,orientation=north,state=u": { "model": "computercraft:block/monitor_normal_u", "y": 270 }, - "facing=east,orientation=north,state=u": { "model": "computercraft:block/monitor_normal_u", "y": 90 }, - "facing=north,orientation=north,state=rd": { "model": "computercraft:block/monitor_normal_rd" }, - "facing=south,orientation=north,state=rd": { "model": "computercraft:block/monitor_normal_rd", "y": 180 }, - "facing=west,orientation=north,state=rd": { "model": "computercraft:block/monitor_normal_rd", "y": 270 }, - "facing=east,orientation=north,state=rd": { "model": "computercraft:block/monitor_normal_rd", "y": 90 }, - "facing=north,orientation=north,state=lrd": { "model": "computercraft:block/monitor_normal_lrd" }, - "facing=south,orientation=north,state=lrd": { "model": "computercraft:block/monitor_normal_lrd", "y": 180 }, - "facing=west,orientation=north,state=lrd": { "model": "computercraft:block/monitor_normal_lrd", "y": 270 }, - "facing=east,orientation=north,state=lrd": { "model": "computercraft:block/monitor_normal_lrd", "y": 90 }, - "facing=north,orientation=north,state=ld": { "model": "computercraft:block/monitor_normal_ld" }, - "facing=south,orientation=north,state=ld": { "model": "computercraft:block/monitor_normal_ld", "y": 180 }, - "facing=west,orientation=north,state=ld": { "model": "computercraft:block/monitor_normal_ld", "y": 270 }, - "facing=east,orientation=north,state=ld": { "model": "computercraft:block/monitor_normal_ld", "y": 90 }, - "facing=north,orientation=north,state=rud": { "model": "computercraft:block/monitor_normal_rud" }, - "facing=south,orientation=north,state=rud": { "model": "computercraft:block/monitor_normal_rud", "y": 180 }, - "facing=west,orientation=north,state=rud": { "model": "computercraft:block/monitor_normal_rud", "y": 270 }, - "facing=east,orientation=north,state=rud": { "model": "computercraft:block/monitor_normal_rud", "y": 90 }, - "facing=north,orientation=north,state=lrud": { "model": "computercraft:block/monitor_normal_lrud" }, - "facing=south,orientation=north,state=lrud": { "model": "computercraft:block/monitor_normal_lrud", "y": 180 }, - "facing=west,orientation=north,state=lrud": { "model": "computercraft:block/monitor_normal_lrud", "y": 270 }, - "facing=east,orientation=north,state=lrud": { "model": "computercraft:block/monitor_normal_lrud", "y": 90 }, - "facing=north,orientation=north,state=lud": { "model": "computercraft:block/monitor_normal_lud" }, - "facing=south,orientation=north,state=lud": { "model": "computercraft:block/monitor_normal_lud", "y": 180 }, - "facing=west,orientation=north,state=lud": { "model": "computercraft:block/monitor_normal_lud", "y": 270 }, - "facing=east,orientation=north,state=lud": { "model": "computercraft:block/monitor_normal_lud", "y": 90 }, - "facing=north,orientation=north,state=ru": { "model": "computercraft:block/monitor_normal_ru" }, - "facing=south,orientation=north,state=ru": { "model": "computercraft:block/monitor_normal_ru", "y": 180 }, - "facing=west,orientation=north,state=ru": { "model": "computercraft:block/monitor_normal_ru", "y": 270 }, - "facing=east,orientation=north,state=ru": { "model": "computercraft:block/monitor_normal_ru", "y": 90 }, - "facing=north,orientation=north,state=lru": { "model": "computercraft:block/monitor_normal_lru" }, - "facing=south,orientation=north,state=lru": { "model": "computercraft:block/monitor_normal_lru", "y": 180 }, - "facing=west,orientation=north,state=lru": { "model": "computercraft:block/monitor_normal_lru", "y": 270 }, - "facing=east,orientation=north,state=lru": { "model": "computercraft:block/monitor_normal_lru", "y": 90 }, - "facing=north,orientation=north,state=lu": { "model": "computercraft:block/monitor_normal_lu" }, - "facing=south,orientation=north,state=lu": { "model": "computercraft:block/monitor_normal_lu", "y": 180 }, - "facing=west,orientation=north,state=lu": { "model": "computercraft:block/monitor_normal_lu", "y": 270 }, - "facing=east,orientation=north,state=lu": { "model": "computercraft:block/monitor_normal_lu", "y": 90 }, - - "facing=north,orientation=up,state=none": { "model": "computercraft:block/monitor_normal", "x": 270 }, - "facing=south,orientation=up,state=none": { "model": "computercraft:block/monitor_normal", "y": 180, "x": 270 }, - "facing=west,orientation=up,state=none": { "model": "computercraft:block/monitor_normal", "y": 270, "x": 270 }, - "facing=east,orientation=up,state=none": { "model": "computercraft:block/monitor_normal", "y": 90, "x": 270 }, - "facing=north,orientation=up,state=r": { "model": "computercraft:block/monitor_normal_r", "x": 270 }, - "facing=south,orientation=up,state=r": { "model": "computercraft:block/monitor_normal_r", "y": 180, "x": 270 }, - "facing=west,orientation=up,state=r": { "model": "computercraft:block/monitor_normal_r", "y": 270, "x": 270 }, - "facing=east,orientation=up,state=r": { "model": "computercraft:block/monitor_normal_r", "y": 90, "x": 270 }, - "facing=north,orientation=up,state=lr": { "model": "computercraft:block/monitor_normal_lr", "x": 270 }, - "facing=south,orientation=up,state=lr": { - "model": "computercraft:block/monitor_normal_lr", "y": 180, "x": 270 - }, - "facing=west,orientation=up,state=lr": { "model": "computercraft:block/monitor_normal_lr", "y": 270, "x": 270 }, - "facing=east,orientation=up,state=lr": { "model": "computercraft:block/monitor_normal_lr", "y": 90, "x": 270 }, - "facing=north,orientation=up,state=l": { "model": "computercraft:block/monitor_normal_l", "x": 270 }, - "facing=south,orientation=up,state=l": { "model": "computercraft:block/monitor_normal_l", "y": 180, "x": 270 }, - "facing=west,orientation=up,state=l": { "model": "computercraft:block/monitor_normal_l", "y": 270, "x": 270 }, - "facing=east,orientation=up,state=l": { "model": "computercraft:block/monitor_normal_l", "y": 90, "x": 270 }, - "facing=north,orientation=up,state=d": { "model": "computercraft:block/monitor_normal_d", "x": 270 }, - "facing=south,orientation=up,state=d": { "model": "computercraft:block/monitor_normal_d", "y": 180, "x": 270 }, - "facing=west,orientation=up,state=d": { "model": "computercraft:block/monitor_normal_d", "y": 270, "x": 270 }, - "facing=east,orientation=up,state=d": { "model": "computercraft:block/monitor_normal_d", "y": 90, "x": 270 }, - "facing=north,orientation=up,state=ud": { "model": "computercraft:block/monitor_normal_ud", "x": 270 }, - "facing=south,orientation=up,state=ud": { - "model": "computercraft:block/monitor_normal_ud", "y": 180, "x": 270 - }, - "facing=west,orientation=up,state=ud": { "model": "computercraft:block/monitor_normal_ud", "y": 270, "x": 270 }, - "facing=east,orientation=up,state=ud": { "model": "computercraft:block/monitor_normal_ud", "y": 90, "x": 270 }, - "facing=north,orientation=up,state=u": { "model": "computercraft:block/monitor_normal_u", "x": 270 }, - "facing=south,orientation=up,state=u": { "model": "computercraft:block/monitor_normal_u", "y": 180, "x": 270 }, - "facing=west,orientation=up,state=u": { "model": "computercraft:block/monitor_normal_u", "y": 270, "x": 270 }, - "facing=east,orientation=up,state=u": { "model": "computercraft:block/monitor_normal_u", "y": 90, "x": 270 }, - "facing=north,orientation=up,state=rd": { "model": "computercraft:block/monitor_normal_rd", "x": 270 }, - "facing=south,orientation=up,state=rd": { - "model": "computercraft:block/monitor_normal_rd", "y": 180, "x": 270 - }, - "facing=west,orientation=up,state=rd": { "model": "computercraft:block/monitor_normal_rd", "y": 270, "x": 270 }, - "facing=east,orientation=up,state=rd": { "model": "computercraft:block/monitor_normal_rd", "y": 90, "x": 270 }, - "facing=north,orientation=up,state=lrd": { "model": "computercraft:block/monitor_normal_lrd", "x": 270 }, - "facing=south,orientation=up,state=lrd": { - "model": "computercraft:block/monitor_normal_lrd", "y": 180, "x": 270 - }, - "facing=west,orientation=up,state=lrd": { - "model": "computercraft:block/monitor_normal_lrd", "y": 270, "x": 270 - }, - "facing=east,orientation=up,state=lrd": { - "model": "computercraft:block/monitor_normal_lrd", "y": 90, "x": 270 - }, - "facing=north,orientation=up,state=ld": { "model": "computercraft:block/monitor_normal_ld", "x": 270 }, - "facing=south,orientation=up,state=ld": { - "model": "computercraft:block/monitor_normal_ld", "y": 180, "x": 270 - }, - "facing=west,orientation=up,state=ld": { "model": "computercraft:block/monitor_normal_ld", "y": 270, "x": 270 }, - "facing=east,orientation=up,state=ld": { "model": "computercraft:block/monitor_normal_ld", "y": 90, "x": 270 }, - "facing=north,orientation=up,state=rud": { "model": "computercraft:block/monitor_normal_rud", "x": 270 }, - "facing=south,orientation=up,state=rud": { - "model": "computercraft:block/monitor_normal_rud", "y": 180, "x": 270 - }, - "facing=west,orientation=up,state=rud": { - "model": "computercraft:block/monitor_normal_rud", "y": 270, "x": 270 - }, - "facing=east,orientation=up,state=rud": { - "model": "computercraft:block/monitor_normal_rud", "y": 90, "x": 270 - }, - "facing=north,orientation=up,state=lrud": { "model": "computercraft:block/monitor_normal_lrud", "x": 270 }, - "facing=south,orientation=up,state=lrud": { - "model": "computercraft:block/monitor_normal_lrud", "y": 180, "x": 270 - }, - "facing=west,orientation=up,state=lrud": { - "model": "computercraft:block/monitor_normal_lrud", "y": 270, "x": 270 - }, - "facing=east,orientation=up,state=lrud": { - "model": "computercraft:block/monitor_normal_lrud", "y": 90, "x": 270 - }, - "facing=north,orientation=up,state=lud": { "model": "computercraft:block/monitor_normal_lud", "x": 270 }, - "facing=south,orientation=up,state=lud": { - "model": "computercraft:block/monitor_normal_lud", "y": 180, "x": 270 - }, - "facing=west,orientation=up,state=lud": { - "model": "computercraft:block/monitor_normal_lud", "y": 270, "x": 270 - }, - "facing=east,orientation=up,state=lud": { - "model": "computercraft:block/monitor_normal_lud", "y": 90, "x": 270 - }, - "facing=north,orientation=up,state=ru": { "model": "computercraft:block/monitor_normal_ru", "x": 270 }, - "facing=south,orientation=up,state=ru": { - "model": "computercraft:block/monitor_normal_ru", "y": 180, "x": 270 - }, - "facing=west,orientation=up,state=ru": { "model": "computercraft:block/monitor_normal_ru", "y": 270, "x": 270 }, - "facing=east,orientation=up,state=ru": { "model": "computercraft:block/monitor_normal_ru", "y": 90, "x": 270 }, - "facing=north,orientation=up,state=lru": { "model": "computercraft:block/monitor_normal_lru", "x": 270 }, - "facing=south,orientation=up,state=lru": { - "model": "computercraft:block/monitor_normal_lru", "y": 180, "x": 270 - }, - "facing=west,orientation=up,state=lru": { - "model": "computercraft:block/monitor_normal_lru", "y": 270, "x": 270 - }, - "facing=east,orientation=up,state=lru": { - "model": "computercraft:block/monitor_normal_lru", "y": 90, "x": 270 - }, - "facing=north,orientation=up,state=lu": { "model": "computercraft:block/monitor_normal_lu", "x": 270 }, - "facing=south,orientation=up,state=lu": { - "model": "computercraft:block/monitor_normal_lu", "y": 180, "x": 270 - }, - "facing=west,orientation=up,state=lu": { "model": "computercraft:block/monitor_normal_lu", "y": 270, "x": 270 }, - "facing=east,orientation=up,state=lu": { "model": "computercraft:block/monitor_normal_lu", "y": 90, "x": 270 }, - - "facing=north,orientation=down,state=none": { "model": "computercraft:block/monitor_normal", "x": 90 }, - "facing=south,orientation=down,state=none": { - "model": "computercraft:block/monitor_normal", "y": 180, "x": 90 - }, - "facing=west,orientation=down,state=none": { "model": "computercraft:block/monitor_normal", "y": 270, "x": 90 }, - "facing=east,orientation=down,state=none": { "model": "computercraft:block/monitor_normal", "y": 90, "x": 90 }, - "facing=north,orientation=down,state=r": { "model": "computercraft:block/monitor_normal_r", "x": 90 }, - "facing=south,orientation=down,state=r": { "model": "computercraft:block/monitor_normal_r", "y": 180, "x": 90 }, - "facing=west,orientation=down,state=r": { "model": "computercraft:block/monitor_normal_r", "y": 270, "x": 90 }, - "facing=east,orientation=down,state=r": { "model": "computercraft:block/monitor_normal_r", "y": 90, "x": 90 }, - "facing=north,orientation=down,state=lr": { "model": "computercraft:block/monitor_normal_lr", "x": 90 }, - "facing=south,orientation=down,state=lr": { - "model": "computercraft:block/monitor_normal_lr", "y": 180, "x": 90 - }, - "facing=west,orientation=down,state=lr": { - "model": "computercraft:block/monitor_normal_lr", "y": 270, "x": 90 - }, - "facing=east,orientation=down,state=lr": { "model": "computercraft:block/monitor_normal_lr", "y": 90, "x": 90 }, - "facing=north,orientation=down,state=l": { "model": "computercraft:block/monitor_normal_l", "x": 90 }, - "facing=south,orientation=down,state=l": { "model": "computercraft:block/monitor_normal_l", "y": 180, "x": 90 }, - "facing=west,orientation=down,state=l": { "model": "computercraft:block/monitor_normal_l", "y": 270, "x": 90 }, - "facing=east,orientation=down,state=l": { "model": "computercraft:block/monitor_normal_l", "y": 90, "x": 90 }, - "facing=north,orientation=down,state=d": { "model": "computercraft:block/monitor_normal_d", "x": 90 }, - "facing=south,orientation=down,state=d": { "model": "computercraft:block/monitor_normal_d", "y": 180, "x": 90 }, - "facing=west,orientation=down,state=d": { "model": "computercraft:block/monitor_normal_d", "y": 270, "x": 90 }, - "facing=east,orientation=down,state=d": { "model": "computercraft:block/monitor_normal_d", "y": 90, "x": 90 }, - "facing=north,orientation=down,state=ud": { "model": "computercraft:block/monitor_normal_ud", "x": 90 }, - "facing=south,orientation=down,state=ud": { - "model": "computercraft:block/monitor_normal_ud", "y": 180, "x": 90 - }, - "facing=west,orientation=down,state=ud": { - "model": "computercraft:block/monitor_normal_ud", "y": 270, "x": 90 - }, - "facing=east,orientation=down,state=ud": { "model": "computercraft:block/monitor_normal_ud", "y": 90, "x": 90 }, - "facing=north,orientation=down,state=u": { "model": "computercraft:block/monitor_normal_u", "x": 90 }, - "facing=south,orientation=down,state=u": { "model": "computercraft:block/monitor_normal_u", "y": 180, "x": 90 }, - "facing=west,orientation=down,state=u": { "model": "computercraft:block/monitor_normal_u", "y": 270, "x": 90 }, - "facing=east,orientation=down,state=u": { "model": "computercraft:block/monitor_normal_u", "y": 90, "x": 90 }, - "facing=north,orientation=down,state=rd": { "model": "computercraft:block/monitor_normal_rd", "x": 90 }, - "facing=south,orientation=down,state=rd": { - "model": "computercraft:block/monitor_normal_rd", "y": 180, "x": 90 - }, - "facing=west,orientation=down,state=rd": { - "model": "computercraft:block/monitor_normal_rd", "y": 270, "x": 90 - }, - "facing=east,orientation=down,state=rd": { "model": "computercraft:block/monitor_normal_rd", "y": 90, "x": 90 }, - "facing=north,orientation=down,state=lrd": { "model": "computercraft:block/monitor_normal_lrd", "x": 90 }, - "facing=south,orientation=down,state=lrd": { - "model": "computercraft:block/monitor_normal_lrd", "y": 180, "x": 90 - }, - "facing=west,orientation=down,state=lrd": { - "model": "computercraft:block/monitor_normal_lrd", "y": 270, "x": 90 - }, - "facing=east,orientation=down,state=lrd": { - "model": "computercraft:block/monitor_normal_lrd", "y": 90, "x": 90 - }, - "facing=north,orientation=down,state=ld": { "model": "computercraft:block/monitor_normal_ld", "x": 90 }, - "facing=south,orientation=down,state=ld": { - "model": "computercraft:block/monitor_normal_ld", "y": 180, "x": 90 - }, - "facing=west,orientation=down,state=ld": { - "model": "computercraft:block/monitor_normal_ld", "y": 270, "x": 90 - }, - "facing=east,orientation=down,state=ld": { "model": "computercraft:block/monitor_normal_ld", "y": 90, "x": 90 }, - "facing=north,orientation=down,state=rud": { "model": "computercraft:block/monitor_normal_rud", "x": 90 }, - "facing=south,orientation=down,state=rud": { - "model": "computercraft:block/monitor_normal_rud", "y": 180, "x": 90 - }, - "facing=west,orientation=down,state=rud": { - "model": "computercraft:block/monitor_normal_rud", "y": 270, "x": 90 - }, - "facing=east,orientation=down,state=rud": { - "model": "computercraft:block/monitor_normal_rud", "y": 90, "x": 90 - }, - "facing=north,orientation=down,state=lrud": { "model": "computercraft:block/monitor_normal_lrud", "x": 90 }, - "facing=south,orientation=down,state=lrud": { - "model": "computercraft:block/monitor_normal_lrud", "y": 180, "x": 90 - }, - "facing=west,orientation=down,state=lrud": { - "model": "computercraft:block/monitor_normal_lrud", "y": 270, "x": 90 - }, - "facing=east,orientation=down,state=lrud": { - "model": "computercraft:block/monitor_normal_lrud", "y": 90, "x": 90 - }, - "facing=north,orientation=down,state=lud": { "model": "computercraft:block/monitor_normal_lud", "x": 90 }, - "facing=south,orientation=down,state=lud": { - "model": "computercraft:block/monitor_normal_lud", "y": 180, "x": 90 - }, - "facing=west,orientation=down,state=lud": { - "model": "computercraft:block/monitor_normal_lud", "y": 270, "x": 90 - }, - "facing=east,orientation=down,state=lud": { - "model": "computercraft:block/monitor_normal_lud", "y": 90, "x": 90 - }, - "facing=north,orientation=down,state=ru": { "model": "computercraft:block/monitor_normal_ru", "x": 90 }, - "facing=south,orientation=down,state=ru": { - "model": "computercraft:block/monitor_normal_ru", "y": 180, "x": 90 - }, - "facing=west,orientation=down,state=ru": { - "model": "computercraft:block/monitor_normal_ru", "y": 270, "x": 90 - }, - "facing=east,orientation=down,state=ru": { "model": "computercraft:block/monitor_normal_ru", "y": 90, "x": 90 }, - "facing=north,orientation=down,state=lru": { "model": "computercraft:block/monitor_normal_lru", "x": 90 }, - "facing=south,orientation=down,state=lru": { - "model": "computercraft:block/monitor_normal_lru", "y": 180, "x": 90 - }, - "facing=west,orientation=down,state=lru": { - "model": "computercraft:block/monitor_normal_lru", "y": 270, "x": 90 - }, - "facing=east,orientation=down,state=lru": { - "model": "computercraft:block/monitor_normal_lru", "y": 90, "x": 90 - }, - "facing=north,orientation=down,state=lu": { "model": "computercraft:block/monitor_normal_lu", "x": 90 }, - "facing=south,orientation=down,state=lu": { - "model": "computercraft:block/monitor_normal_lu", "y": 180, "x": 90 - }, - "facing=west,orientation=down,state=lu": { - "model": "computercraft:block/monitor_normal_lu", "y": 270, "x": 90 - }, - "facing=east,orientation=down,state=lu": { "model": "computercraft:block/monitor_normal_lu", "y": 90, "x": 90 } - } -} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_advanced.json b/src/main/resources/assets/computercraft/models/block/monitor_advanced.json deleted file mode 100644 index 3ff0ed5dc..000000000 --- a/src/main/resources/assets/computercraft/models/block/monitor_advanced.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:block/monitor_advanced_16", - "side": "computercraft:block/monitor_advanced_4", - "top": "computercraft:block/monitor_advanced_0", - "back": "computercraft:block/monitor_advanced_4" - } -} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_advanced_d.json b/src/main/resources/assets/computercraft/models/block/monitor_advanced_d.json deleted file mode 100644 index d8936956d..000000000 --- a/src/main/resources/assets/computercraft/models/block/monitor_advanced_d.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:block/monitor_advanced_20", - "side": "computercraft:block/monitor_advanced_36", - "top": "computercraft:block/monitor_advanced_0", - "back": "computercraft:block/monitor_advanced_36" - } -} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_advanced_l.json b/src/main/resources/assets/computercraft/models/block/monitor_advanced_l.json deleted file mode 100644 index 3abee2204..000000000 --- a/src/main/resources/assets/computercraft/models/block/monitor_advanced_l.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:block/monitor_advanced_19", - "side": "computercraft:block/monitor_advanced_4", - "top": "computercraft:block/monitor_advanced_1", - "back": "computercraft:block/monitor_advanced_33" - } -} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_advanced_ld.json b/src/main/resources/assets/computercraft/models/block/monitor_advanced_ld.json deleted file mode 100644 index ee054dbc8..000000000 --- a/src/main/resources/assets/computercraft/models/block/monitor_advanced_ld.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:block/monitor_advanced_31", - "side": "computercraft:block/monitor_advanced_7", - "top": "computercraft:block/monitor_advanced_1", - "back": "computercraft:block/monitor_advanced_45" - } -} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_advanced_lr.json b/src/main/resources/assets/computercraft/models/block/monitor_advanced_lr.json deleted file mode 100644 index 320c8d354..000000000 --- a/src/main/resources/assets/computercraft/models/block/monitor_advanced_lr.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:block/monitor_advanced_18", - "side": "computercraft:block/monitor_advanced_4", - "top": "computercraft:block/monitor_advanced_2", - "back": "computercraft:block/monitor_advanced_34" - } -} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_advanced_lrd.json b/src/main/resources/assets/computercraft/models/block/monitor_advanced_lrd.json deleted file mode 100644 index 5f7a43407..000000000 --- a/src/main/resources/assets/computercraft/models/block/monitor_advanced_lrd.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:block/monitor_advanced_30", - "side": "computercraft:block/monitor_advanced_7", - "top": "computercraft:block/monitor_advanced_2", - "back": "computercraft:block/monitor_advanced_46" - } -} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_advanced_lru.json b/src/main/resources/assets/computercraft/models/block/monitor_advanced_lru.json deleted file mode 100644 index 56acdd077..000000000 --- a/src/main/resources/assets/computercraft/models/block/monitor_advanced_lru.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:block/monitor_advanced_24", - "side": "computercraft:block/monitor_advanced_38", - "top": "computercraft:block/monitor_advanced_2", - "back": "computercraft:block/monitor_advanced_40" - } -} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_advanced_lrud.json b/src/main/resources/assets/computercraft/models/block/monitor_advanced_lrud.json deleted file mode 100644 index dce3c2baf..000000000 --- a/src/main/resources/assets/computercraft/models/block/monitor_advanced_lrud.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:block/monitor_advanced_27", - "side": "computercraft:block/monitor_advanced_37", - "top": "computercraft:block/monitor_advanced_2", - "back": "computercraft:block/monitor_advanced_43" - } -} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_advanced_lu.json b/src/main/resources/assets/computercraft/models/block/monitor_advanced_lu.json deleted file mode 100644 index 905ebdce3..000000000 --- a/src/main/resources/assets/computercraft/models/block/monitor_advanced_lu.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:block/monitor_advanced_25", - "side": "computercraft:block/monitor_advanced_38", - "top": "computercraft:block/monitor_advanced_1", - "back": "computercraft:block/monitor_advanced_39" - } -} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_advanced_lud.json b/src/main/resources/assets/computercraft/models/block/monitor_advanced_lud.json deleted file mode 100644 index 43b110c03..000000000 --- a/src/main/resources/assets/computercraft/models/block/monitor_advanced_lud.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:block/monitor_advanced_28", - "side": "computercraft:block/monitor_advanced_37", - "top": "computercraft:block/monitor_advanced_1", - "back": "computercraft:block/monitor_advanced_42" - } -} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_advanced_r.json b/src/main/resources/assets/computercraft/models/block/monitor_advanced_r.json deleted file mode 100644 index 03d1d386f..000000000 --- a/src/main/resources/assets/computercraft/models/block/monitor_advanced_r.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:block/monitor_advanced_17", - "side": "computercraft:block/monitor_advanced_4", - "top": "computercraft:block/monitor_advanced_3", - "back": "computercraft:block/monitor_advanced_35" - } -} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_advanced_rd.json b/src/main/resources/assets/computercraft/models/block/monitor_advanced_rd.json deleted file mode 100644 index 4ded80dba..000000000 --- a/src/main/resources/assets/computercraft/models/block/monitor_advanced_rd.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:block/monitor_advanced_29", - "side": "computercraft:block/monitor_advanced_7", - "top": "computercraft:block/monitor_advanced_3", - "back": "computercraft:block/monitor_advanced_47" - } -} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_advanced_ru.json b/src/main/resources/assets/computercraft/models/block/monitor_advanced_ru.json deleted file mode 100644 index 67cd36920..000000000 --- a/src/main/resources/assets/computercraft/models/block/monitor_advanced_ru.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:block/monitor_advanced_23", - "side": "computercraft:block/monitor_advanced_38", - "top": "computercraft:block/monitor_advanced_3", - "back": "computercraft:block/monitor_advanced_41" - } -} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_advanced_rud.json b/src/main/resources/assets/computercraft/models/block/monitor_advanced_rud.json deleted file mode 100644 index 0573ad049..000000000 --- a/src/main/resources/assets/computercraft/models/block/monitor_advanced_rud.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:block/monitor_advanced_26", - "side": "computercraft:block/monitor_advanced_37", - "top": "computercraft:block/monitor_advanced_3", - "back": "computercraft:block/monitor_advanced_44" - } -} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_advanced_u.json b/src/main/resources/assets/computercraft/models/block/monitor_advanced_u.json deleted file mode 100644 index bdc9f7a2d..000000000 --- a/src/main/resources/assets/computercraft/models/block/monitor_advanced_u.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:block/monitor_advanced_22", - "side": "computercraft:block/monitor_advanced_38", - "top": "computercraft:block/monitor_advanced_0", - "back": "computercraft:block/monitor_advanced_38" - } -} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_advanced_ud.json b/src/main/resources/assets/computercraft/models/block/monitor_advanced_ud.json deleted file mode 100644 index 3987b109f..000000000 --- a/src/main/resources/assets/computercraft/models/block/monitor_advanced_ud.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:block/monitor_advanced_21", - "side": "computercraft:block/monitor_advanced_37", - "top": "computercraft:block/monitor_advanced_0", - "back": "computercraft:block/monitor_advanced_37" - } -} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_normal.json b/src/main/resources/assets/computercraft/models/block/monitor_normal.json deleted file mode 100644 index e7a669695..000000000 --- a/src/main/resources/assets/computercraft/models/block/monitor_normal.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:block/monitor_normal_16", - "side": "computercraft:block/monitor_normal_4", - "top": "computercraft:block/monitor_normal_0", - "back": "computercraft:block/monitor_normal_4" - } -} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_normal_l.json b/src/main/resources/assets/computercraft/models/block/monitor_normal_l.json deleted file mode 100644 index def167210..000000000 --- a/src/main/resources/assets/computercraft/models/block/monitor_normal_l.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:block/monitor_normal_19", - "side": "computercraft:block/monitor_normal_4", - "top": "computercraft:block/monitor_normal_1", - "back": "computercraft:block/monitor_normal_33" - } -} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_normal_ld.json b/src/main/resources/assets/computercraft/models/block/monitor_normal_ld.json deleted file mode 100644 index 410d65029..000000000 --- a/src/main/resources/assets/computercraft/models/block/monitor_normal_ld.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:block/monitor_normal_31", - "side": "computercraft:block/monitor_normal_7", - "top": "computercraft:block/monitor_normal_1", - "back": "computercraft:block/monitor_normal_45" - } -} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_normal_lr.json b/src/main/resources/assets/computercraft/models/block/monitor_normal_lr.json deleted file mode 100644 index 36243944d..000000000 --- a/src/main/resources/assets/computercraft/models/block/monitor_normal_lr.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:block/monitor_normal_18", - "side": "computercraft:block/monitor_normal_4", - "top": "computercraft:block/monitor_normal_2", - "back": "computercraft:block/monitor_normal_34" - } -} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_normal_lrd.json b/src/main/resources/assets/computercraft/models/block/monitor_normal_lrd.json deleted file mode 100644 index 1fe673561..000000000 --- a/src/main/resources/assets/computercraft/models/block/monitor_normal_lrd.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:block/monitor_normal_30", - "side": "computercraft:block/monitor_normal_7", - "top": "computercraft:block/monitor_normal_2", - "back": "computercraft:block/monitor_normal_46" - } -} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_normal_lru.json b/src/main/resources/assets/computercraft/models/block/monitor_normal_lru.json deleted file mode 100644 index d6c5b2ce4..000000000 --- a/src/main/resources/assets/computercraft/models/block/monitor_normal_lru.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:block/monitor_normal_24", - "side": "computercraft:block/monitor_normal_38", - "top": "computercraft:block/monitor_normal_2", - "back": "computercraft:block/monitor_normal_40" - } -} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_normal_lrud.json b/src/main/resources/assets/computercraft/models/block/monitor_normal_lrud.json deleted file mode 100644 index ba96ee76d..000000000 --- a/src/main/resources/assets/computercraft/models/block/monitor_normal_lrud.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:block/monitor_normal_27", - "side": "computercraft:block/monitor_normal_37", - "top": "computercraft:block/monitor_normal_2", - "back": "computercraft:block/monitor_normal_43" - } -} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_normal_lu.json b/src/main/resources/assets/computercraft/models/block/monitor_normal_lu.json deleted file mode 100644 index 444408d25..000000000 --- a/src/main/resources/assets/computercraft/models/block/monitor_normal_lu.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:block/monitor_normal_25", - "side": "computercraft:block/monitor_normal_38", - "top": "computercraft:block/monitor_normal_1", - "back": "computercraft:block/monitor_normal_39" - } -} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_normal_lud.json b/src/main/resources/assets/computercraft/models/block/monitor_normal_lud.json deleted file mode 100644 index 28f06d420..000000000 --- a/src/main/resources/assets/computercraft/models/block/monitor_normal_lud.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:block/monitor_normal_28", - "side": "computercraft:block/monitor_normal_37", - "top": "computercraft:block/monitor_normal_1", - "back": "computercraft:block/monitor_normal_42" - } -} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_normal_r.json b/src/main/resources/assets/computercraft/models/block/monitor_normal_r.json deleted file mode 100644 index 8b8eb4df1..000000000 --- a/src/main/resources/assets/computercraft/models/block/monitor_normal_r.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:block/monitor_normal_17", - "side": "computercraft:block/monitor_normal_4", - "top": "computercraft:block/monitor_normal_3", - "back": "computercraft:block/monitor_normal_35" - } -} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_normal_rd.json b/src/main/resources/assets/computercraft/models/block/monitor_normal_rd.json deleted file mode 100644 index 61d7d1231..000000000 --- a/src/main/resources/assets/computercraft/models/block/monitor_normal_rd.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:block/monitor_normal_29", - "side": "computercraft:block/monitor_normal_7", - "top": "computercraft:block/monitor_normal_3", - "back": "computercraft:block/monitor_normal_47" - } -} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_normal_ru.json b/src/main/resources/assets/computercraft/models/block/monitor_normal_ru.json deleted file mode 100644 index ddb474736..000000000 --- a/src/main/resources/assets/computercraft/models/block/monitor_normal_ru.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:block/monitor_normal_23", - "side": "computercraft:block/monitor_normal_38", - "top": "computercraft:block/monitor_normal_3", - "back": "computercraft:block/monitor_normal_41" - } -} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_normal_rud.json b/src/main/resources/assets/computercraft/models/block/monitor_normal_rud.json deleted file mode 100644 index a8f272995..000000000 --- a/src/main/resources/assets/computercraft/models/block/monitor_normal_rud.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:block/monitor_normal_26", - "side": "computercraft:block/monitor_normal_37", - "top": "computercraft:block/monitor_normal_3", - "back": "computercraft:block/monitor_normal_44" - } -} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_normal_u.json b/src/main/resources/assets/computercraft/models/block/monitor_normal_u.json deleted file mode 100644 index c7d67619b..000000000 --- a/src/main/resources/assets/computercraft/models/block/monitor_normal_u.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:block/monitor_normal_22", - "side": "computercraft:block/monitor_normal_38", - "top": "computercraft:block/monitor_normal_0", - "back": "computercraft:block/monitor_normal_38" - } -} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_normal_ud.json b/src/main/resources/assets/computercraft/models/block/monitor_normal_ud.json deleted file mode 100644 index 0cbadcc4b..000000000 --- a/src/main/resources/assets/computercraft/models/block/monitor_normal_ud.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:block/monitor_normal_21", - "side": "computercraft:block/monitor_normal_37", - "top": "computercraft:block/monitor_normal_0", - "back": "computercraft:block/monitor_normal_37" - } -} From a4c9e89370ddb80ec4cf8f9560c585b5b61cc7dc Mon Sep 17 00:00:00 2001 From: Jonathan Coates Date: Thu, 12 Nov 2020 19:01:50 +0000 Subject: [PATCH 02/38] Runnable examples (#576) Provides a basic interface for running examples on tweaked.cc. This is probably janky as anything, but it works on my machine. This is the culmination of 18 months of me building far too much infrastructure (copy-cat, illuaminate), so that's nice I guess. I should probably get out more. --- .editorconfig | 1 - .github/workflows/make-doc.sh | 2 +- .github/workflows/make-doc.yml | 18 ++-- .gitignore | 10 +- build.gradle | 52 +++++++++- doc/styles.css | 14 --- illuaminate.sexp | 24 +++-- package-lock.json | 172 ++++++++++++++++++++++++++++++++ package.json | 18 ++++ rollup.config.js | 49 +++++++++ src/web/copy-cat.d.ts | 21 ++++ src/web/index.tsx | 155 ++++++++++++++++++++++++++++ src/web/mount/.settings | 3 + src/web/mount/expr_template.lua | 14 +++ src/web/mount/startup.lua | 5 + src/web/styles.css | 85 ++++++++++++++++ tools/check-lines.py | 2 +- tsconfig.json | 34 +++++++ 18 files changed, 639 insertions(+), 40 deletions(-) delete mode 100644 doc/styles.css create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 rollup.config.js create mode 100644 src/web/copy-cat.d.ts create mode 100644 src/web/index.tsx create mode 100644 src/web/mount/.settings create mode 100644 src/web/mount/expr_template.lua create mode 100644 src/web/mount/startup.lua create mode 100644 src/web/styles.css create mode 100644 tsconfig.json diff --git a/.editorconfig b/.editorconfig index d57b269a4..f5f23d8d4 100644 --- a/.editorconfig +++ b/.editorconfig @@ -17,6 +17,5 @@ indent_size = 2 [*.yml] indent_size = 2 - [*.properties] insert_final_newline = false diff --git a/.github/workflows/make-doc.sh b/.github/workflows/make-doc.sh index f7446f84c..f86ef60f0 100755 --- a/.github/workflows/make-doc.sh +++ b/.github/workflows/make-doc.sh @@ -12,5 +12,5 @@ chmod 600 "$HOME/.ssh/key" # And upload rsync -avc -e "ssh -i $HOME/.ssh/key -o StrictHostKeyChecking=no -p $SSH_PORT" \ - "$GITHUB_WORKSPACE/doc/out/" \ + "$GITHUB_WORKSPACE/build/docs/lua/" \ "$SSH_USER@$SSH_HOST:/var/www/tweaked.cc/$DEST" diff --git a/.github/workflows/make-doc.yml b/.github/workflows/make-doc.yml index 3abf5d265..18ce815a5 100644 --- a/.github/workflows/make-doc.yml +++ b/.github/workflows/make-doc.yml @@ -30,18 +30,20 @@ jobs: restore-keys: | ${{ runner.os }}-gradle- - - name: Build with Gradle - run: ./gradlew compileJava --no-daemon || ./gradlew compileJava --no-daemon - - - name: Generate Java documentation stubs - run: ./gradlew luaJavadoc --no-daemon - - - name: Build documentation + - name: Setup illuaminate run: | test -d bin || mkdir bin test -f bin/illuaminate || wget -q -Obin/illuaminate https://squiddev.cc/illuaminate/linux-x86-64/illuaminate chmod +x bin/illuaminate - bin/illuaminate doc-gen + + - name: Setup node + run: npm ci + + - name: Build with Gradle + run: ./gradlew compileJava --no-daemon || ./gradlew compileJava --no-daemon + + - name: Generate documentation + run: ./gradlew docWebsite --no-daemon - name: Upload documentation run: .github/workflows/make-doc.sh 2> /dev/null diff --git a/.gitignore b/.gitignore index 84f17aee8..808032e6d 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,7 @@ /build /out /doc/out/ -/doc/javadoc/ +/node_modules # Runtime directories /run @@ -18,10 +18,12 @@ .gradle *.DS_Store -.classpath -.project -.settings/ +/.classpath +/.project +/.settings +/.vscode bin/ *.launch /src/generated/resources/.cache +/src/web/mount/*.d.ts diff --git a/build.gradle b/build.gradle index 33a414ab9..5c36a17fd 100644 --- a/build.gradle +++ b/build.gradle @@ -136,7 +136,7 @@ task luaJavadoc(type: Javadoc) { group "documentation" source = sourceSets.main.allJava - destinationDir = file("doc/javadoc") + destinationDir = file("${project.docsDir}/luaJavadoc") classpath = sourceSets.main.compileClasspath options.docletpath = configurations.cctJavadoc.files as List @@ -306,6 +306,56 @@ task compressJson(dependsOn: jar) { assemble.dependsOn compressJson +// Web tasks + +import org.apache.tools.ant.taskdefs.condition.Os + +List mkCommand(String command) { + return Os.isFamily(Os.FAMILY_WINDOWS) ? ["cmd", "/c", command] : ["sh", "-c", command] +} + +task rollup(type: Exec) { + group = "build" + description = "Bundles JS into rollup" + + inputs.files(fileTree("src/web")).withPropertyName("sources") + inputs.file("package-lock.json").withPropertyName("package-lock.json") + inputs.file("tsconfig.json").withPropertyName("Typescript config") + inputs.file("rollup.config.js").withPropertyName("Rollup config") + outputs.file("$buildDir/rollup/index.js").withPropertyName("output") + + commandLine mkCommand('"node_modules/.bin/rollup" --config rollup.config.js') +} + +task minifyWeb(type: Exec, dependsOn: rollup) { + group = "build" + description = "Bundles JS into rollup" + + inputs.file("$buildDir/rollup/index.js").withPropertyName("sources") + inputs.file("package-lock.json").withPropertyName("package-lock.json") + outputs.file("$buildDir/rollup/index.min.js").withPropertyName("output") + + commandLine mkCommand('"node_modules/.bin/terser"' + " -o $buildDir/rollup/index.min.js $buildDir/rollup/index.js") +} + +task illuaminateDocs(type: Exec, dependsOn: [minifyWeb, luaJavadoc]) { + group = "build" + description = "Bundles JS into rollup" + + inputs.files(fileTree("doc")).withPropertyName("sources") + inputs.file("illuaminate.sexp").withPropertyName("illuaminate.sexp") + inputs.file("$buildDir/rollup/index.min.js").withPropertyName("scripts") + inputs.file("src/web/styles.css").withPropertyName("styles") + outputs.dir("$buildDir/docs/lua") + + commandLine mkCommand('"bin/illuaminate" doc-gen') +} + +task docWebsite(type: Copy, dependsOn: [illuaminateDocs]) { + from 'doc/logo.png' + into "${project.docsDir}/lua" +} + // Check tasks test { diff --git a/doc/styles.css b/doc/styles.css deleted file mode 100644 index a21b9ac34..000000000 --- a/doc/styles.css +++ /dev/null @@ -1,14 +0,0 @@ -/* Pretty tables, mostly inherited from table.definition-list */ -table.pretty-table { - border-collapse: collapse; - width: 100%; -} - -table.pretty-table td, table.pretty-table th { - border: 1px solid #cccccc; - padding: 2px 4px; -} - -table.pretty-table th { - background-color: #f0f0f0; -} diff --git a/illuaminate.sexp b/illuaminate.sexp index 558028975..80a481a64 100644 --- a/illuaminate.sexp +++ b/illuaminate.sexp @@ -2,18 +2,20 @@ (sources /doc/stub/ - /doc/javadoc/ + /build/docs/luaJavadoc/ /src/main/resources/*/computercraft/lua/bios.lua /src/main/resources/*/computercraft/lua/rom/ - /src/test/resources/test-rom) + /src/test/resources/test-rom + /src/web/mount) (doc (title "CC: Tweaked") - (destination doc/out) + (destination build/docs/lua) (logo src/main/resources/pack.png) (index doc/index.md) - (styles doc/styles.css) + (styles src/web/styles.css) + (scripts build/rollup/index.js) (source-link https://github.com/SquidDev-CC/CC-Tweaked/blob/${commit}/${path}#L${line}) (module-kinds @@ -21,7 +23,7 @@ (library-path /doc/stub/ - /doc/javadoc/ + /build/docs/luaJavadoc/ /src/main/resources/*/computercraft/lua/rom/apis /src/main/resources/*/computercraft/lua/rom/apis/command @@ -72,7 +74,7 @@ (lint (allow-toplevel-global true))) ;; Silence some variable warnings in documentation stubs. -(at (/doc/stub/ /doc/javadoc/) +(at (/doc/stub/ /build/docs/luaJavadoc/) (linters -var:unused-global) (lint (allow-toplevel-global true))) @@ -84,11 +86,11 @@ /doc/stub/turtle.lua /doc/stub/global.lua ; Java generated APIs - /doc/javadoc/turtle.lua + /build/docs/luaJavadoc/turtle.lua ; Peripherals - /doc/javadoc/drive.lua - /doc/javadoc/speaker.lua - /doc/javadoc/printer.lua + /build/docs/luaJavadoc/drive.lua + /build/docs/luaJavadoc/speaker.lua + /build/docs/luaJavadoc/printer.lua ; Lua APIs /src/main/resources/*/computercraft/lua/rom/apis/io.lua /src/main/resources/*/computercraft/lua/rom/apis/window.lua) @@ -116,3 +118,5 @@ (globals :max sleep write cct_test describe expect howlci fail it pending stub))) + +(at /src/web/mount/expr_template.lua (lint (globals :max __expr__))) diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 000000000..b12022dac --- /dev/null +++ b/package-lock.json @@ -0,0 +1,172 @@ +{ + "name": "tweaked.cc", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@rollup/plugin-typescript": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-typescript/-/plugin-typescript-6.1.0.tgz", + "integrity": "sha512-hJxaiE6WyNOsK+fZpbFh9CUijZYqPQuAOWO5khaGTUkM8DYNNyA2TDlgamecE+qLOG1G1+CwbWMAx3rbqpp6xQ==", + "dev": true, + "requires": { + "@rollup/pluginutils": "^3.1.0", + "resolve": "^1.17.0" + } + }, + "@rollup/pluginutils": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.1.0.tgz", + "integrity": "sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==", + "dev": true, + "requires": { + "@types/estree": "0.0.39", + "estree-walker": "^1.0.1", + "picomatch": "^2.2.2" + } + }, + "@types/estree": { + "version": "0.0.39", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz", + "integrity": "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==", + "dev": true + }, + "buffer-from": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", + "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", + "dev": true + }, + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true + }, + "estree-walker": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-1.0.1.tgz", + "integrity": "sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==", + "dev": true + }, + "fsevents": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.1.3.tgz", + "integrity": "sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ==", + "dev": true, + "optional": true + }, + "function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "dev": true + }, + "has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dev": true, + "requires": { + "function-bind": "^1.1.1" + } + }, + "is-core-module": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.1.0.tgz", + "integrity": "sha512-YcV7BgVMRFRua2FqQzKtTDMz8iCuLEyGKjr70q8Zm1yy2qKcurbFEd79PAdHV77oL3NrAaOVQIbMmiHQCHB7ZA==", + "dev": true, + "requires": { + "has": "^1.0.3" + } + }, + "path-parse": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", + "dev": true + }, + "picomatch": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz", + "integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==", + "dev": true + }, + "preact": { + "version": "10.5.5", + "resolved": "https://registry.npmjs.org/preact/-/preact-10.5.5.tgz", + "integrity": "sha512-5ONLNH1SXMzzbQoExZX4TELemNt+TEDb622xXFNfZngjjM9qtrzseJt+EfiUu4TZ6EJ95X5sE1ES4yqHFSIdhg==" + }, + "requirejs": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/requirejs/-/requirejs-2.3.6.tgz", + "integrity": "sha512-ipEzlWQe6RK3jkzikgCupiTbTvm4S0/CAU5GlgptkN5SO6F3u0UD0K18wy6ErDqiCyP4J4YYe1HuAShvsxePLg==", + "dev": true + }, + "resolve": { + "version": "1.18.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.18.1.tgz", + "integrity": "sha512-lDfCPaMKfOJXjy0dPayzPdF1phampNWr3qFCjAu+rw/qbQmr5jWH5xN2hwh9QKfw9E5v4hwV7A+jrCmL8yjjqA==", + "dev": true, + "requires": { + "is-core-module": "^2.0.0", + "path-parse": "^1.0.6" + } + }, + "rollup": { + "version": "2.33.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.33.1.tgz", + "integrity": "sha512-uY4O/IoL9oNW8MMcbA5hcOaz6tZTMIh7qJHx/tzIJm+n1wLoY38BLn6fuy7DhR57oNFLMbDQtDeJoFURt5933w==", + "dev": true, + "requires": { + "fsevents": "~2.1.2" + } + }, + "source-map": { + "version": "0.7.3", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz", + "integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==", + "dev": true + }, + "source-map-support": { + "version": "0.5.19", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", + "integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==", + "dev": true, + "requires": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + } + } + }, + "terser": { + "version": "5.3.8", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.3.8.tgz", + "integrity": "sha512-zVotuHoIfnYjtlurOouTazciEfL7V38QMAOhGqpXDEg6yT13cF4+fEP9b0rrCEQTn+tT46uxgFsTZzhygk+CzQ==", + "dev": true, + "requires": { + "commander": "^2.20.0", + "source-map": "~0.7.2", + "source-map-support": "~0.5.19" + } + }, + "tslib": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.0.3.tgz", + "integrity": "sha512-uZtkfKblCEQtZKBF6EBXVZeQNl82yqtDQdv+eck8u7tdPxjLu2/lp5/uPW+um2tpuxINHWy3GhiccY7QgEaVHQ==" + }, + "typescript": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.0.5.tgz", + "integrity": "sha512-ywmr/VrTVCmNTJ6iV2LwIrfG1P+lv6luD8sUJs+2eI9NLGigaN+nUQc13iHqisq7bra9lnmUSYqbJvegraBOPQ==", + "dev": true + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 000000000..682f93de0 --- /dev/null +++ b/package.json @@ -0,0 +1,18 @@ +{ + "name": "tweaked.cc", + "version": "1.0.0", + "description": "Website additions for tweaked.cc", + "author": "SquidDev", + "license": "BSD-3-Clause", + "dependencies": { + "preact": "^10.5.5", + "tslib": "^2.0.3" + }, + "devDependencies": { + "@rollup/plugin-typescript": "^6.1.0", + "requirejs": "^2.3.6", + "rollup": "^2.33.1", + "terser": "^5.3.8", + "typescript": "^4.0.5" + } +} diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 000000000..1e0342fea --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,49 @@ +import { readFileSync, promises as fs } from "fs"; +import path from "path"; + +import typescript from "@rollup/plugin-typescript"; + +const input = "src/web"; +const requirejs = readFileSync("node_modules/requirejs/require.js"); + +export default { + input: [`${input}/index.tsx`], + output: { + file: "build/rollup/index.js", + // We bundle requirejs (and config) into the header. It's rather gross + // but also works reasonably well. + banner: `${requirejs}\nrequire.config({ paths: { copycat: "https://copy-cat.squiddev.cc" } });`, + format: "amd", + preferConst: true, + amd: { + define: "require", + } + }, + context: "window", + external: ["copycat/embed"], + + plugins: [ + typescript(), + + { + name: "cc-tweaked", + async options(options) { + // Generate .d.ts files for all /mount files. This is the worst way to do it, + // but we need to run before the TS pass. + const template = "declare const contents : string;\nexport default contents;\n"; + const files = await fs.readdir(`${input}/mount`); + + await Promise.all(files + .filter(x => path.extname(x) !== ".ts") + .map(file => fs.writeFile(`${input}/mount/${file}.d.ts`, template)) + ); + return options; + }, + async transform(code, file) { + // Allow loading files in /mount. + if (path.extname(file) != ".lua" && path.basename(file) != ".settings") return null; + return `export default ${JSON.stringify(code)};\n`; + }, + } + ], +}; diff --git a/src/web/copy-cat.d.ts b/src/web/copy-cat.d.ts new file mode 100644 index 000000000..b4a85d267 --- /dev/null +++ b/src/web/copy-cat.d.ts @@ -0,0 +1,21 @@ +import { h, Component, render, ComponentChild } from "preact"; + +export { h, Component, render }; + +export type ComputerAccess = unknown; + +export type MainProps = { + hdFont?: boolean | string, + persistId?: number, + files?: { [filename: string]: string | ArrayBuffer }, + label?: string, + width?: number, + height?: number, + resolve?: (computer: ComputerAccess) => void, +} + +declare class Computer extends Component { + public render(props: MainProps, state: unknown): ComponentChild; +} + +export { Computer }; diff --git a/src/web/index.tsx b/src/web/index.tsx new file mode 100644 index 000000000..0bf476a86 --- /dev/null +++ b/src/web/index.tsx @@ -0,0 +1,155 @@ +import { render, h, Component, Computer } from "copycat/embed"; +import type { ComponentChild } from "preact"; + +import settingsFile from "./mount/.settings"; +import startupFile from "./mount/startup.lua"; +import exprTemplate from "./mount/expr_template.lua"; + +const defaultFiles: { [filename: string]: string } = { + ".settings": settingsFile, + "startup.lua": startupFile, +}; + +const clamp = (value: number, min: number, max: number): number => { + if (value < min) return min; + if (value > max) return max; + return value; +} + +const Click = (options: { run: () => void }) => + + +type WindowProps = {}; + +type WindowState = { + visible: boolean, + + example: string, + exampleIdx: number, +} + +type Touch = { clientX: number, clientY: number }; + +class Window extends Component { + private positioned: boolean = false; + private left: number = 0; + private top: number = 0; + private dragging?: { downX: number, downY: number, initialX: number, initialY: number }; + + constructor(props: WindowProps, context: unknown) { + super(props, context); + + this.state = { + visible: false, + example: "", + exampleIdx: 0, + } + } + + componentDidMount() { + const elements = document.querySelectorAll("pre[data-lua-kind]"); + for (let i = 0; i < elements.length; i++) { + const element = elements[i] as HTMLElement; + + let example = element.innerText; + if (element.getAttribute("data-lua-kind") == "expr") { + example = exprTemplate.replace("__expr__", example); + } + render(, element); + } + } + + componentDidUpdate(_: WindowProps, { visible }: WindowState) { + if (!visible && this.state.visible) this.setPosition(this.left, this.top); + } + + public render(_: WindowProps, { visible, example, exampleIdx }: WindowState): ComponentChild { + return visible ?
+
+
+ +
+
+ +
+
:
; + } + + private runExample(example: string): () => void { + return () => { + if (!this.positioned) { + this.positioned = true; + this.left = 20; + this.top = 20; + } + + this.setState(({ exampleIdx }: WindowState) => ({ + visible: true, + example: example, + exampleIdx: exampleIdx + 1, + })); + } + } + + private readonly close = () => this.setState({ visible: false }); + + // All the dragging code is terrible. However, I've had massive performance + // issues doing it other ways, so this'll have to do. + private onDown(e: Event, touch: Touch) { + e.stopPropagation(); + e.preventDefault(); + + this.dragging = { + initialX: this.left, initialY: this.top, + downX: touch.clientX, downY: touch.clientY + }; + + window.addEventListener("mousemove", this.onMouseDrag, true); + window.addEventListener("touchmove", this.onTouchDrag, true); + window.addEventListener("mouseup", this.onUp, true); + window.addEventListener("touchend", this.onUp, true); + } + private readonly onMouseDown = (e: MouseEvent) => this.onDown(e, e); + private readonly onTouchDown = (e: TouchEvent) => this.onDown(e, e.touches[0]); + + private onDrag(e: Event, touch: Touch) { + e.stopPropagation(); + e.preventDefault(); + + const dragging = this.dragging; + if (!dragging) return; + + this.setPosition( + dragging.initialX + (touch.clientX - dragging.downX), + dragging.initialY + (touch.clientY - dragging.downY), + ); + }; + private readonly onMouseDrag = (e: MouseEvent) => this.onDrag(e, e); + private readonly onTouchDrag = (e: TouchEvent) => this.onDrag(e, e.touches[0]); + + private readonly onUp = (e: Event) => { + e.stopPropagation(); + + this.dragging = undefined; + + window.removeEventListener("mousemove", this.onMouseDrag, true); + window.removeEventListener("touchmove", this.onTouchDrag, true); + window.removeEventListener("mouseup", this.onUp, true); + window.removeEventListener("touchend", this.onUp, true); + } + + private readonly setPosition = (left: number, top: number): void => { + const root = this.base as HTMLElement; + + left = this.left = clamp(left, 0, window.innerWidth - root.offsetWidth); + top = this.top = clamp(top, 0, window.innerHeight - root.offsetHeight); + root.style.transform = `translate(${left}px, ${top}px)`; + } + +} + +const root = document.createElement("div"); +document.body.appendChild(root); +render(, document.body, root); diff --git a/src/web/mount/.settings b/src/web/mount/.settings new file mode 100644 index 000000000..5b9849575 --- /dev/null +++ b/src/web/mount/.settings @@ -0,0 +1,3 @@ +{ + [ "motd.enable" ] = false, +} diff --git a/src/web/mount/expr_template.lua b/src/web/mount/expr_template.lua new file mode 100644 index 000000000..37faf4180 --- /dev/null +++ b/src/web/mount/expr_template.lua @@ -0,0 +1,14 @@ +local result = table.pack(__expr__ +) + +if result.n == 0 then return end + +local pp = require "cc.pretty" + +local line = {} +for i = 1, result.n do + if i > 1 then line[#line + 1] = pp.text(", ") end + line[#line + 1] = pp.pretty(result[i]) +end + +pp.print(pp.concat(table.unpack(line))) diff --git a/src/web/mount/startup.lua b/src/web/mount/startup.lua new file mode 100644 index 000000000..91bbf535f --- /dev/null +++ b/src/web/mount/startup.lua @@ -0,0 +1,5 @@ +-- Make the startup file invisible, then run the file. We could use +-- shell.run, but this ensures the program is in shell history, etc... +fs.delete("startup.lua") +os.queueEvent("paste", "example.lua") +os.queueEvent("key", keys.enter, false) diff --git a/src/web/styles.css b/src/web/styles.css new file mode 100644 index 000000000..e60e670ee --- /dev/null +++ b/src/web/styles.css @@ -0,0 +1,85 @@ +/* Pretty tables, mostly inherited from table.definition-list */ +table.pretty-table { + border-collapse: collapse; + width: 100%; +} + +table.pretty-table td, table.pretty-table th { + border: 1px solid #cccccc; + padding: 2px 4px; +} + +table.pretty-table th { + background-color: #f0f0f0; +} + +.highlight.highlight-lua { + position: relative; + background: #eee; + padding: 2px; +} + +.example-run { + position: absolute; + top: 0; + right: 0; + background: #058e05; + color: #fff; + padding: 2px 5px; +} + +.example-window { + position: fixed; + z-index: 200; + top: 0px; + top: 0px;; +} + +/* Behold, the most cursed CSS! copy-cat's resizing algorithm is a weird, in + that it basically does "wrapper height - 40px" to determine the effective + size. But the footer is actually 1em+6px high, so we need to do very weird + things. + + Yes, it should probably be fixed on the copy-cat side. + */ +.computer-container { + width: 620px; + height: calc(350px + 40px); + margin-top: calc((1em + 6px - 40px) / 2); +} + +.example-window-hidden { + display: none; +} + +.titlebar { + display: flex; + background: #dede6c; + height: 30px; +} + +.titlebar-drag { + flex-grow: 1; + cursor: grab; +} + +.titlebar-close { + background: none; + padding: 0px 5px; + border: none; + border-radius: 0px; + margin: 0px; + font-size: 15px; +} + +.titlebar-close:hover { background: #cc4c4c; } + +@media (max-width: 700px) { + .computer-container { + width: 314px; + height: calc(179px + 40px); + } + + .titlebar { height: 20px; } + .titlebar-close { font-size: 7px; } +} diff --git a/tools/check-lines.py b/tools/check-lines.py index 3659924ae..47ff15fc9 100644 --- a/tools/check-lines.py +++ b/tools/check-lines.py @@ -18,7 +18,7 @@ for path in pathlib.Path("src").glob("**/*"): if line.strip() == "": print("%s has empty first line" % path) - if len(line) >= 2 and line[-2] == "\r" and line[-1] == "\n" and not has_line: + if len(line) >= 2 and line[-2] == "\r" and line[-1] == "\n" and not has_dos: print("%s has contains '\\r\\n' on line %d" % (path, i + 1)) problems = has_dos = True diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 000000000..b6dc1da3f --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,34 @@ +{ + "compilerOptions": { + "module": "esNext", + "moduleResolution": "node", + "target": "es6", + "lib": [ + "es2015", + "dom" + ], + "newLine": "LF", + "baseUrl": ".", + // Additional compile options + "noEmitOnError": true, + "preserveWatchOutput": true, + "jsx": "react", + "jsxFactory": "h", + // Strict Type-Checking Options + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "importsNotUsedAsValues": "error", + "forceConsistentCasingInFileNames": true, + "paths": { + "copycat/embed": [ + "src/web/copy-cat.d.ts" + ], + } + }, + "include": [ + "src/web", + ] +} From ab39cb849d9a356378c359931ad1546ad6937f00 Mon Sep 17 00:00:00 2001 From: SquidDev Date: Thu, 12 Nov 2020 19:04:55 +0000 Subject: [PATCH 03/38] Publish Javadoc to tweaked.cc too Closes #578 Also only publish docs for 1.15.x trunk for now. Tags aren't especially useful until we add a version switcher. --- .github/workflows/make-doc.sh | 3 +++ .github/workflows/make-doc.yml | 6 +----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/make-doc.sh b/.github/workflows/make-doc.sh index f86ef60f0..802426430 100755 --- a/.github/workflows/make-doc.sh +++ b/.github/workflows/make-doc.sh @@ -14,3 +14,6 @@ chmod 600 "$HOME/.ssh/key" rsync -avc -e "ssh -i $HOME/.ssh/key -o StrictHostKeyChecking=no -p $SSH_PORT" \ "$GITHUB_WORKSPACE/build/docs/lua/" \ "$SSH_USER@$SSH_HOST:/var/www/tweaked.cc/$DEST" +rsync -avc -e "ssh -i $HOME/.ssh/key -o StrictHostKeyChecking=no -p $SSH_PORT" \ + "$GITHUB_WORKSPACE/build/docs/javadoc/" \ + "$SSH_USER@$SSH_HOST:/var/www/tweaked.cc/$DEST/javadoc" diff --git a/.github/workflows/make-doc.yml b/.github/workflows/make-doc.yml index 18ce815a5..ab7d60b1a 100644 --- a/.github/workflows/make-doc.yml +++ b/.github/workflows/make-doc.yml @@ -3,11 +3,7 @@ name: Build documentation on: push: branches: - - master - mc-1.15.x - tags: - release: - types: [ published ] jobs: make_doc: @@ -43,7 +39,7 @@ jobs: run: ./gradlew compileJava --no-daemon || ./gradlew compileJava --no-daemon - name: Generate documentation - run: ./gradlew docWebsite --no-daemon + run: ./gradlew docWebsite javadoc --no-daemon - name: Upload documentation run: .github/workflows/make-doc.sh 2> /dev/null From 9f57e77ed367611b4f33fda650edc2b65435ae88 Mon Sep 17 00:00:00 2001 From: SquidDev Date: Thu, 12 Nov 2020 19:12:03 +0000 Subject: [PATCH 04/38] Add a link to the Java docs --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index d344fb157..6ce3f3df9 100644 --- a/README.md +++ b/README.md @@ -67,3 +67,6 @@ dependencies { You should also be careful to only use classes within the `dan200.computercraft.api` package. Non-API classes are subject to change at any point. If you depend on functionality outside the API, file an issue, and we can look into exposing more features. + +We bundle the API sources with the jar, so documentation should be easily viewable within your editor. Alternatively, +the generated documentation [can be browsed online](https://tweaked.cc/javadoc/). From 7f90f2f7cadce0d5b9177b16626979591bce8137 Mon Sep 17 00:00:00 2001 From: SquidDev Date: Thu, 12 Nov 2020 19:40:18 +0000 Subject: [PATCH 05/38] Clean up some examples a little bit Would be good if they didn't crash and burn on entry :). --- doc/stub/fs.lua | 2 +- doc/stub/os.lua | 6 +++++- illuaminate.sexp | 9 --------- .../data/computercraft/lua/rom/apis/colors.lua | 8 ++++---- .../data/computercraft/lua/rom/apis/disk.lua | 2 +- .../data/computercraft/lua/rom/apis/help.lua | 3 ++- .../data/computercraft/lua/rom/apis/keys.lua | 1 + .../data/computercraft/lua/rom/apis/peripheral.lua | 2 +- .../data/computercraft/lua/rom/apis/textutils.lua | 12 ++++++------ .../lua/rom/modules/main/cc/completion.lua | 4 ++-- .../computercraft/lua/rom/modules/main/cc/pretty.lua | 4 ++-- .../lua/rom/modules/main/cc/shell/completion.lua | 2 +- .../data/computercraft/lua/rom/programs/shell.lua | 4 ++-- 13 files changed, 28 insertions(+), 31 deletions(-) diff --git a/doc/stub/fs.lua b/doc/stub/fs.lua index 6e3b56c84..40b9107db 100644 --- a/doc/stub/fs.lua +++ b/doc/stub/fs.lua @@ -15,7 +15,7 @@ function isDriveRoot(path) end --[[- Provides completion for a file or directory name, suitable for use with -@{read}. +@{_G.read}. When a directory is a possible candidate for completion, two entries are included - one with a trailing slash (indicating that entries within this diff --git a/doc/stub/os.lua b/doc/stub/os.lua index 7da3ea0c3..89a472bf3 100644 --- a/doc/stub/os.lua +++ b/doc/stub/os.lua @@ -85,6 +85,9 @@ the `terminate` event yourself - the program will not stop execution when function pullEventRaw(filter) end --- Pauses execution for the specified number of seconds, alias of @{_G.sleep}. +-- +-- @tparam number time The number of seconds to sleep for, rounded up to the +-- nearest multiple of 0.05. function sleep(time) end --- Get the current CraftOS version (for example, `CraftOS 1.8`). @@ -93,6 +96,7 @@ function sleep(time) end -- should return `CraftOS 1.8`. -- -- @treturn string The current CraftOS version. +-- @usage os.version() function version() end --[[- Run the program at the given path with the specified environment and @@ -113,7 +117,7 @@ such as @{loadfile}. @treturn boolean Whether or not the program ran successfully. @usage Run the default shell from within your program: - os.run({}, "/rom/programs/shell") + os.run({}, "/rom/programs/shell.lua") @see shell.run @see loadfile diff --git a/illuaminate.sexp b/illuaminate.sexp index 80a481a64..6bf2d2688 100644 --- a/illuaminate.sexp +++ b/illuaminate.sexp @@ -97,15 +97,6 @@ (linters -doc:undocumented -doc:undocumented-arg -doc:undocumented-return)) -;; These currently rely on unknown references. -(at - (/src/main/resources/*/computercraft/lua/rom/apis/textutils.lua - /src/main/resources/*/computercraft/lua/rom/modules/main/cc/completion.lua - /src/main/resources/*/computercraft/lua/rom/modules/main/cc/shell/completion.lua - /src/main/resources/*/computercraft/lua/rom/programs/shell.lua - /doc/stub/fs.lua) - (linters -doc:unresolved-reference)) - ;; Suppress warnings for the BIOS using its own deprecated members for now. (at /src/main/resources/*/computercraft/lua/bios.lua (linters -var:deprecated)) diff --git a/src/main/resources/data/computercraft/lua/rom/apis/colors.lua b/src/main/resources/data/computercraft/lua/rom/apis/colors.lua index 83c8e0f21..ba4050763 100644 --- a/src/main/resources/data/computercraft/lua/rom/apis/colors.lua +++ b/src/main/resources/data/computercraft/lua/rom/apis/colors.lua @@ -270,7 +270,7 @@ end -- @treturn number The combined hexadecimal colour. -- @usage -- ```lua --- colors.rgb(0.7, 0.2, 0.6) +-- colors.packRGB(0.7, 0.2, 0.6) -- -- => 0xb23399 -- ``` function packRGB(r, g, b) @@ -291,7 +291,7 @@ end -- @treturn number The blue channel, will be between 0 and 1. -- @usage -- ```lua --- colors.rgb(0xb23399) +-- colors.unpackRGB(0xb23399) -- -- => 0.7, 0.2, 0.6 -- ``` -- @see colors.packRGB @@ -317,12 +317,12 @@ end -- @deprecated Use @{packRGB} or @{unpackRGB} directly. -- @usage -- ```lua --- colors.rgb(0xb23399) +-- colors.rgb8(0xb23399) -- -- => 0.7, 0.2, 0.6 -- ``` -- @usage -- ```lua --- colors.rgb(0.7, 0.2, 0.6) +-- colors.rgb8(0.7, 0.2, 0.6) -- -- => 0xb23399 -- ``` function rgb8(r, g, b) diff --git a/src/main/resources/data/computercraft/lua/rom/apis/disk.lua b/src/main/resources/data/computercraft/lua/rom/apis/disk.lua index 9e136b22c..ca5ac21d2 100644 --- a/src/main/resources/data/computercraft/lua/rom/apis/disk.lua +++ b/src/main/resources/data/computercraft/lua/rom/apis/disk.lua @@ -22,7 +22,7 @@ end -- -- @tparam string name The name of the disk drive. -- @treturn boolean If something is in the disk drive. --- @usage disk.isPresent(false) +-- @usage disk.isPresent("top") function isPresent(name) if isDrive(name) then return peripheral.call(name, "isDiskPresent") diff --git a/src/main/resources/data/computercraft/lua/rom/apis/help.lua b/src/main/resources/data/computercraft/lua/rom/apis/help.lua index 438af474f..777ab45bf 100644 --- a/src/main/resources/data/computercraft/lua/rom/apis/help.lua +++ b/src/main/resources/data/computercraft/lua/rom/apis/help.lua @@ -32,7 +32,7 @@ end -- @tparam string topic The topic to find -- @treturn string|nil The path to the given topic's help file, or `nil` if it -- cannot be found. --- @usage print(help.lookup("disk")) +-- @usage help.lookup("disk") function lookup(_sTopic) expect(1, _sTopic, "string") -- Look on the path variable @@ -52,6 +52,7 @@ end --- Returns a list of topics that can be looked up and/or displayed. -- -- @treturn table A list of topics in alphabetical order. +-- @usage help.topics() function topics() -- Add index local tItems = { diff --git a/src/main/resources/data/computercraft/lua/rom/apis/keys.lua b/src/main/resources/data/computercraft/lua/rom/apis/keys.lua index 90f877aa5..206646c21 100644 --- a/src/main/resources/data/computercraft/lua/rom/apis/keys.lua +++ b/src/main/resources/data/computercraft/lua/rom/apis/keys.lua @@ -145,6 +145,7 @@ keys.cimcumflex = keys.circumflex --- @local -- -- @tparam number code The key code to look up. -- @treturn string|nil The name of the key, or `nil` if not a valid key code. +-- @usage keys.getName(keys.enter) function getName(_nKey) expect(1, _nKey, "number") return tKeys[_nKey] diff --git a/src/main/resources/data/computercraft/lua/rom/apis/peripheral.lua b/src/main/resources/data/computercraft/lua/rom/apis/peripheral.lua index d8be09ad3..c284d0691 100644 --- a/src/main/resources/data/computercraft/lua/rom/apis/peripheral.lua +++ b/src/main/resources/data/computercraft/lua/rom/apis/peripheral.lua @@ -191,7 +191,7 @@ end -- filter function, which takes the peripheral's name and wrapped table -- and returns if it should be included in the result. -- @treturn table... 0 or more wrapped peripherals matching the given filters. --- @usage local monitors = { peripheral.find("monitor") } +-- @usage { peripheral.find("monitor") } -- @usage peripheral.find("modem", rednet.open) function find(ty, filter) expect(1, ty, "string") diff --git a/src/main/resources/data/computercraft/lua/rom/apis/textutils.lua b/src/main/resources/data/computercraft/lua/rom/apis/textutils.lua index e6156d3b0..ec0633589 100644 --- a/src/main/resources/data/computercraft/lua/rom/apis/textutils.lua +++ b/src/main/resources/data/computercraft/lua/rom/apis/textutils.lua @@ -9,7 +9,7 @@ local expect, field = expect.expect, expect.field --- Slowly writes string text at current cursor position, -- character-by-character. -- --- Like @{write}, this does not insert a newline at the end. +-- Like @{_G.write}, this does not insert a newline at the end. -- -- @tparam string sText The the text to write to the screen -- @tparam[opt] number nRate The number of characters to write each second, @@ -119,8 +119,8 @@ end -- displayed before prompting. -- @treturn number The number of lines printed. -- @usage --- local width, height = term.getSize() --- textutils.pagedPrint(("This is a rather verbose dose of repetition.\n"):rep(30), height - 2) +-- local width, height = term.getSize() +-- textutils.pagedPrint(("This is a rather verbose dose of repetition.\n"):rep(30), height - 2) function pagedPrint(_sText, _nFreeLines) expect(2, _nFreeLines, "number", "nil") -- Setup a redirector @@ -706,7 +706,7 @@ unserialiseJSON = unserialise_json -- -- @tparam string str The string to encode -- @treturn string The encoded string. --- @usage print("https://example.com/?view=" .. textutils.urlEncode(read())) +-- @usage print("https://example.com/?view=" .. textutils.urlEncode("some text&things")) function urlEncode(str) expect(1, str, "string") if str then @@ -744,8 +744,8 @@ local tEmpty = {} -- -- @treturn { string... } The (possibly empty) list of completions. -- @see shell.setCompletionFunction --- @see read --- @usage textutils.complete( "pa", getfenv() ) +-- @see _G.read +-- @usage textutils.complete( "pa", _ENV ) function complete(sSearchText, tSearchTable) expect(1, sSearchText, "string") expect(2, tSearchTable, "table", "nil") diff --git a/src/main/resources/data/computercraft/lua/rom/modules/main/cc/completion.lua b/src/main/resources/data/computercraft/lua/rom/modules/main/cc/completion.lua index 2ae2e4966..01cc187b1 100644 --- a/src/main/resources/data/computercraft/lua/rom/modules/main/cc/completion.lua +++ b/src/main/resources/data/computercraft/lua/rom/modules/main/cc/completion.lua @@ -1,5 +1,5 @@ --- A collection of helper methods for working with input completion, such --- as that require by @{read}. +-- as that require by @{_G.read}. -- -- @module cc.completion -- @see cc.shell.completion For additional helpers to use with @@ -29,7 +29,7 @@ end -- @tparam { string... } choices The list of choices to complete from. -- @tparam[opt] boolean add_space Whether to add a space after the completed item. -- @treturn { string... } A list of suffixes of matching strings. --- @usage Call @{read}, completing the names of various animals. +-- @usage Call @{_G.read}, completing the names of various animals. -- -- local animals = { "dog", "cat", "lion", "unicorn" } -- read(nil, nil, function(text) return choice(text, animals) end) diff --git a/src/main/resources/data/computercraft/lua/rom/modules/main/cc/pretty.lua b/src/main/resources/data/computercraft/lua/rom/modules/main/cc/pretty.lua index a62a6f9f1..1c782ecee 100644 --- a/src/main/resources/data/computercraft/lua/rom/modules/main/cc/pretty.lua +++ b/src/main/resources/data/computercraft/lua/rom/modules/main/cc/pretty.lua @@ -13,11 +13,11 @@ -- @module cc.pretty -- @usage Print a table to the terminal -- local pretty = require "cc.pretty" --- pretty.write(pretty.pretty({ 1, 2, 3 })) +-- pretty.print(pretty.pretty({ 1, 2, 3 })) -- -- @usage Build a custom document and display it -- local pretty = require "cc.pretty" --- pretty.write(pretty.group(pretty.text("hello") .. pretty.space_line .. pretty.text("world"))) +-- pretty.print(pretty.group(pretty.text("hello") .. pretty.space_line .. pretty.text("world"))) local expect = require "cc.expect" local expect, field = expect.expect, expect.field diff --git a/src/main/resources/data/computercraft/lua/rom/modules/main/cc/shell/completion.lua b/src/main/resources/data/computercraft/lua/rom/modules/main/cc/shell/completion.lua index 91d9ea7a4..21c10ec34 100644 --- a/src/main/resources/data/computercraft/lua/rom/modules/main/cc/shell/completion.lua +++ b/src/main/resources/data/computercraft/lua/rom/modules/main/cc/shell/completion.lua @@ -8,7 +8,7 @@ -- wrap them using @{build}, or your own custom function. -- -- @module cc.shell.completion --- @see cc.completion For more general helpers, suitable for use with @{read}. +-- @see cc.completion For more general helpers, suitable for use with @{_G.read}. -- @see shell.setCompletionFunction local expect = require "cc.expect".expect diff --git a/src/main/resources/data/computercraft/lua/rom/programs/shell.lua b/src/main/resources/data/computercraft/lua/rom/programs/shell.lua index 0c6b5868b..1cc6dfe48 100644 --- a/src/main/resources/data/computercraft/lua/rom/programs/shell.lua +++ b/src/main/resources/data/computercraft/lua/rom/programs/shell.lua @@ -383,7 +383,7 @@ end -- -- @tparam string sLine The input to complete. -- @treturn { string }|nil The list of possible completions. --- @see read For more information about completion. +-- @see _G.read For more information about completion. -- @see shell.completeProgram -- @see shell.setCompletionFunction -- @see shell.getCompletionInfo @@ -461,7 +461,7 @@ end -- The completion function. -- @see cc.shell.completion Various utilities to help with writing completion functions. -- @see shell.complete --- @see read For more information about completion. +-- @see _G.read For more information about completion. function shell.setCompletionFunction(program, complete) expect(1, program, "string") expect(2, complete, "function") From f194f4fa3a17c48ff1a9088d50063f4a675a23b6 Mon Sep 17 00:00:00 2001 From: Stephen Gibson Date: Fri, 13 Nov 2020 14:32:49 +0000 Subject: [PATCH 06/38] Fix epoch documentation to use milliseconds (#580) --- .../java/dan200/computercraft/core/apis/OSAPI.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/dan200/computercraft/core/apis/OSAPI.java b/src/main/java/dan200/computercraft/core/apis/OSAPI.java index be5dbb2dd..b0752cdaa 100644 --- a/src/main/java/dan200/computercraft/core/apis/OSAPI.java +++ b/src/main/java/dan200/computercraft/core/apis/OSAPI.java @@ -378,17 +378,17 @@ public class OSAPI implements ILuaAPI } /** - * Returns the number of seconds since an epoch depending on the locale. + * Returns the number of milliseconds since an epoch depending on the locale. * - * * If called with {@code ingame}, returns the number of seconds since the + * * If called with {@code ingame}, returns the number of milliseconds since the * world was created. This is the default. - * * If called with {@code utc}, returns the number of seconds since 1 + * * If called with {@code utc}, returns the number of milliseconds since 1 * January 1970 in the UTC timezone. - * * If called with {@code local}, returns the number of seconds since 1 + * * If called with {@code local}, returns the number of milliseconds since 1 * January 1970 in the server's local timezone. * - * @param args The locale to get the seconds for. Defaults to {@code ingame} if not set. - * @return The seconds since the epoch depending on the selected locale. + * @param args The locale to get the milliseconds for. Defaults to {@code ingame} if not set. + * @return The milliseconds since the epoch depending on the selected locale. * @throws LuaException If an invalid locale is passed. */ @LuaFunction From d2a1a00dc43e5b65f6b64111ce76dd3db16c919f Mon Sep 17 00:00:00 2001 From: Luca Date: Tue, 17 Nov 2020 13:53:20 +0100 Subject: [PATCH 07/38] Clear gets an option to reset the palette (#582) Fixes #555. --- .../data/computercraft/lua/rom/help/clear.txt | 7 +++- .../computercraft/lua/rom/programs/clear.lua | 35 +++++++++++++++++-- .../data/computercraft/lua/rom/startup.lua | 1 + 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/src/main/resources/data/computercraft/lua/rom/help/clear.txt b/src/main/resources/data/computercraft/lua/rom/help/clear.txt index 6e3258411..037d3c8a5 100644 --- a/src/main/resources/data/computercraft/lua/rom/help/clear.txt +++ b/src/main/resources/data/computercraft/lua/rom/help/clear.txt @@ -1 +1,6 @@ -clear clears the screen. +clear clears the screen and/or resets the palette. +ex: +"clear" clears the screen, but keeps the palette. +"clear screen" does the same as "clear" +"clear palette" resets the palette, but doesn't clear the screen +"clear all" clears the screen and resets the palette diff --git a/src/main/resources/data/computercraft/lua/rom/programs/clear.lua b/src/main/resources/data/computercraft/lua/rom/programs/clear.lua index d69a29993..cfd8cb9c4 100644 --- a/src/main/resources/data/computercraft/lua/rom/programs/clear.lua +++ b/src/main/resources/data/computercraft/lua/rom/programs/clear.lua @@ -1,2 +1,33 @@ -term.clear() -term.setCursorPos(1, 1) +local tArgs = { ... } + +local function printUsage() + local programName = arg[0] or fs.getName(shell.getRunningProgram()) + print("Usages:") + print(programName) + print(programName .. " screen") + print(programName .. " palette") + print(programName .. " all") +end + +local function clear() + term.clear() + term.setCursorPos(1, 1) +end + +local function resetPalette() + for i = 0, 15 do + term.setPaletteColour(math.pow(2, i), term.nativePaletteColour(math.pow(2, i))) + end +end + +local sCommand = tArgs[1] or "screen" +if sCommand == "screen" then + clear() +elseif sCommand == "palette" then + resetPalette() +elseif sCommand == "all" then + clear() + resetPalette() +else + printUsage() +end diff --git a/src/main/resources/data/computercraft/lua/rom/startup.lua b/src/main/resources/data/computercraft/lua/rom/startup.lua index 1b3046092..8c347cc33 100644 --- a/src/main/resources/data/computercraft/lua/rom/startup.lua +++ b/src/main/resources/data/computercraft/lua/rom/startup.lua @@ -49,6 +49,7 @@ end shell.setCompletionFunction("rom/programs/alias.lua", completion.build(nil, completion.program)) shell.setCompletionFunction("rom/programs/cd.lua", completion.build(completion.dir)) +shell.setCompletionFunction("rom/programs/clear.lua", completion.build({ completion.choice, { "screen", "palette", "all" } })) shell.setCompletionFunction("rom/programs/copy.lua", completion.build( { completion.dirOrFile, true }, completion.dirOrFile From aab0cd34cd64fdf837ff1c3b91a957a25c2cf7f9 Mon Sep 17 00:00:00 2001 From: SquidDev Date: Fri, 20 Nov 2020 15:06:47 +0000 Subject: [PATCH 08/38] Use term.blit on original paint render This makes it super speedy, meaning an initial refresh doesn't take ages to load. --- .../lua/rom/programs/fun/advanced/paint.lua | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/main/resources/data/computercraft/lua/rom/programs/fun/advanced/paint.lua b/src/main/resources/data/computercraft/lua/rom/programs/fun/advanced/paint.lua index cb9de4153..cab2cfc6c 100644 --- a/src/main/resources/data/computercraft/lua/rom/programs/fun/advanced/paint.lua +++ b/src/main/resources/data/computercraft/lua/rom/programs/fun/advanced/paint.lua @@ -233,14 +233,32 @@ local function drawCanvasPixel(x, y) end end +local color_hex_lookup = {} +for i = 0, 15 do + color_hex_lookup[2 ^ i] = string.format("%x", i) +end + --[[ Converts each colour in a single line of the canvas and draws it returns: nil ]] local function drawCanvasLine(y) + local text, fg, bg = "", "", "" for x = 1, w - 2 do - drawCanvasPixel(x, y) + local pixel = getCanvasPixel(x, y) + if pixel then + text = text .. " " + fg = fg .. "0" + bg = bg .. color_hex_lookup[pixel or canvasColour] + else + text = text .. "\127" + fg = fg .. color_hex_lookup[canvasColour] + bg = bg .. color_hex_lookup[colours.grey] + end end + + term.setCursorPos(1, y) + term.blit(text, fg, bg) end --[[ From b0651082f472baee8f0fa8ec7ba95f433e2637bb Mon Sep 17 00:00:00 2001 From: SquidDev Date: Fri, 20 Nov 2020 19:36:28 +0000 Subject: [PATCH 09/38] Cleanup examples for the various modules --- build.gradle | 3 +- .../lua/rom/modules/main/cc/completion.lua | 19 +++- .../lua/rom/modules/main/cc/expect.lua | 27 +++++- .../lua/rom/modules/main/cc/pretty.lua | 20 +++- .../lua/rom/modules/main/cc/require.lua | 6 +- .../rom/modules/main/cc/shell/completion.lua | 91 ++++++++++--------- 6 files changed, 109 insertions(+), 57 deletions(-) diff --git a/build.gradle b/build.gradle index 5c36a17fd..4f698a445 100644 --- a/build.gradle +++ b/build.gradle @@ -342,7 +342,8 @@ task illuaminateDocs(type: Exec, dependsOn: [minifyWeb, luaJavadoc]) { group = "build" description = "Bundles JS into rollup" - inputs.files(fileTree("doc")).withPropertyName("sources") + inputs.files(fileTree("doc")).withPropertyName("docs") + inputs.files(fileTree("src/main/resources/data/computercraft/lua/rom")).withPropertyName("lua rom") inputs.file("illuaminate.sexp").withPropertyName("illuaminate.sexp") inputs.file("$buildDir/rollup/index.min.js").withPropertyName("scripts") inputs.file("src/web/styles.css").withPropertyName("styles") diff --git a/src/main/resources/data/computercraft/lua/rom/modules/main/cc/completion.lua b/src/main/resources/data/computercraft/lua/rom/modules/main/cc/completion.lua index 01cc187b1..d07b09506 100644 --- a/src/main/resources/data/computercraft/lua/rom/modules/main/cc/completion.lua +++ b/src/main/resources/data/computercraft/lua/rom/modules/main/cc/completion.lua @@ -31,8 +31,9 @@ end -- @treturn { string... } A list of suffixes of matching strings. -- @usage Call @{_G.read}, completing the names of various animals. -- +-- local completion = require "cc.completion" -- local animals = { "dog", "cat", "lion", "unicorn" } --- read(nil, nil, function(text) return choice(text, animals) end) +-- read(nil, nil, function(text) return completion.choice(text, animals) end) local function choice(text, choices, add_space) expect(1, text, "string") expect(2, choices, "table") @@ -45,7 +46,9 @@ end -- @tparam string text The input string to complete. -- @tparam[opt] boolean add_space Whether to add a space after the completed name. -- @treturn { string... } A list of suffixes of matching peripherals. --- @usage read(nil, nil, peripheral) +-- @usage +-- local completion = require "cc.completion" +-- read(nil, nil, completion.peripheral) local function peripheral_(text, add_space) expect(1, text, "string") expect(2, add_space, "boolean", "nil") @@ -59,7 +62,9 @@ local sides = redstone.getSides() -- @tparam string text The input string to complete. -- @tparam[opt] boolean add_space Whether to add a space after the completed side. -- @treturn { string... } A list of suffixes of matching sides. --- @usage read(nil, nil, side) +-- @usage +-- local completion = require "cc.completion" +-- read(nil, nil, completion.side) local function side(text, add_space) expect(1, text, "string") expect(2, add_space, "boolean", "nil") @@ -71,7 +76,9 @@ end -- @tparam string text The input string to complete. -- @tparam[opt] boolean add_space Whether to add a space after the completed settings. -- @treturn { string... } A list of suffixes of matching settings. --- @usage read(nil, nil, setting) +-- @usage +-- local completion = require "cc.completion" +-- read(nil, nil, completion.setting) local function setting(text, add_space) expect(1, text, "string") expect(2, add_space, "boolean", "nil") @@ -85,7 +92,9 @@ local command_list -- @tparam string text The input string to complete. -- @tparam[opt] boolean add_space Whether to add a space after the completed command. -- @treturn { string... } A list of suffixes of matching commands. --- @usage read(nil, nil, command) +-- @usage +-- local completion = require "cc.completion" +-- read(nil, nil, completion.command) local function command(text, add_space) expect(1, text, "string") expect(2, add_space, "boolean", "nil") diff --git a/src/main/resources/data/computercraft/lua/rom/modules/main/cc/expect.lua b/src/main/resources/data/computercraft/lua/rom/modules/main/cc/expect.lua index 24ca66d56..397be085e 100644 --- a/src/main/resources/data/computercraft/lua/rom/modules/main/cc/expect.lua +++ b/src/main/resources/data/computercraft/lua/rom/modules/main/cc/expect.lua @@ -1,7 +1,26 @@ ---- The @{cc.expect} library provides helper functions for verifying that --- function arguments are well-formed and of the correct type. --- --- @module cc.expect +--[[- The @{cc.expect} library provides helper functions for verifying that +function arguments are well-formed and of the correct type. + +@module cc.expect +@usage Define a basic function and check it has the correct arguments. + + local expect = require "cc.expect" + local expect, field = expect.expect, expect.field + + local function add_person(name, info) + expect(1, name, "string") + expect(2, info, "table", "nil") + + if info then + print("Got age=", field(info, "age", "number")) + print("Got gender=", field(info, "gender", "string", "nil")) + end + end + + add_person("Anastazja") -- `info' is optional + add_person("Kion", { age = 23 }) -- `gender' is optional + add_person("Caoimhin", { age = 23, gender = true }) -- error! +]] local native_select, native_type = select, type diff --git a/src/main/resources/data/computercraft/lua/rom/modules/main/cc/pretty.lua b/src/main/resources/data/computercraft/lua/rom/modules/main/cc/pretty.lua index 1c782ecee..37a70a515 100644 --- a/src/main/resources/data/computercraft/lua/rom/modules/main/cc/pretty.lua +++ b/src/main/resources/data/computercraft/lua/rom/modules/main/cc/pretty.lua @@ -67,6 +67,9 @@ end -- @tparam[opt] number colour The colour this text should be printed with. If not given, we default to the current -- colour. -- @treturn Doc The document with the provided text. +-- @usage Write some blue text. +-- local pretty = require "cc.pretty" +-- pretty.print(pretty.text("Hello!", colours.blue)) local function text(text, colour) expect(1, text, "string") expect(2, colour, "number", "nil") @@ -101,8 +104,11 @@ end -- -- @tparam Doc|string ... The documents to concatenate. -- @treturn Doc The concatenated documents. --- @usage pretty.concat(doc1, " - ", doc2) --- @usage doc1 .. " - " .. doc2 +-- @usage +-- local pretty = require "cc.pretty" +-- local doc1, doc2 = pretty.text("doc1"), pretty.text("doc2") +-- print(pretty.concat(doc1, " - ", doc2)) +-- print(doc1 .. " - " .. doc2) -- Also supports .. local function concat(...) local args = table.pack(...) for i = 1, args.n do @@ -135,7 +141,9 @@ Doc.__concat = concat --- @local -- @tparam number depth The number of spaces with which the document should be indented. -- @tparam Doc doc The document to indent. -- @treturn Doc The nested document. --- @usage pretty.nest(2, pretty.text("foo\nbar")) +-- @usage +-- local pretty = require "cc.pretty" +-- print(pretty.nest(2, pretty.text("foo\nbar"))) local function nest(depth, doc) expect(1, depth, "number") if getmetatable(doc) ~= Doc then expect(2, doc, "document") end @@ -169,6 +177,12 @@ end -- -- @tparam Doc doc The document to group. -- @treturn Doc The grouped document. +-- @usage Uses group to show things being displayed on one or multiple lines. +-- +-- local pretty = require "cc.pretty" +-- local doc = pretty.group("Hello" .. pretty.space_line .. "World") +-- print(pretty.render(doc, 5)) -- On multiple lines +-- print(pretty.render(doc, 20)) -- Collapsed onto one. local function group(doc) if getmetatable(doc) ~= Doc then expect(1, doc, "document") end diff --git a/src/main/resources/data/computercraft/lua/rom/modules/main/cc/require.lua b/src/main/resources/data/computercraft/lua/rom/modules/main/cc/require.lua index a90e189b8..c7b2e2741 100644 --- a/src/main/resources/data/computercraft/lua/rom/modules/main/cc/require.lua +++ b/src/main/resources/data/computercraft/lua/rom/modules/main/cc/require.lua @@ -9,9 +9,13 @@ -- @usage Construct the package and require function, and insert them into a -- custom environment. -- --- local env = setmetatable({}, { __index = _ENV }) -- local r = require "cc.require" +-- local env = setmetatable({}, { __index = _ENV }) -- env.require, env.package = r.make(env, "/") +-- +-- -- Now we have our own require function, separate to the original. +-- local r2 = env.require "cc.require" +-- print(r, r2) local expect = require and require("cc.expect") or dofile("rom/modules/main/cc/expect.lua") local expect = expect.expect diff --git a/src/main/resources/data/computercraft/lua/rom/modules/main/cc/shell/completion.lua b/src/main/resources/data/computercraft/lua/rom/modules/main/cc/shell/completion.lua index 21c10ec34..06619c7f1 100644 --- a/src/main/resources/data/computercraft/lua/rom/modules/main/cc/shell/completion.lua +++ b/src/main/resources/data/computercraft/lua/rom/modules/main/cc/shell/completion.lua @@ -1,15 +1,28 @@ ---- A collection of helper methods for working with shell completion. --- --- Most programs may be completed using the @{build} helper method, rather than --- manually switching on the argument index. --- --- Note, the helper functions within this module do not accept an argument index, --- and so are not directly usable with the @{shell.setCompletionFunction}. Instead, --- wrap them using @{build}, or your own custom function. --- --- @module cc.shell.completion --- @see cc.completion For more general helpers, suitable for use with @{_G.read}. --- @see shell.setCompletionFunction +--[[- A collection of helper methods for working with shell completion. + +Most programs may be completed using the @{build} helper method, rather than +manually switching on the argument index. + +Note, the helper functions within this module do not accept an argument index, +and so are not directly usable with the @{shell.setCompletionFunction}. Instead, +wrap them using @{build}, or your own custom function. + +@module cc.shell.completion +@see cc.completion For more general helpers, suitable for use with @{_G.read}. +@see shell.setCompletionFunction + +@usage Register a completion handler for example.lua which prompts for a +choice of options, followed by a directory, and then multiple files. + + local completion = require "cc.shell.completion" + local complete = completion.build( + { completion.choice, { "get", "put" } }, + completion.dir, + { completion.file, many = true } + ) + shell.setCompletionFunction("example.lua", complete) + read(nil, nil, shell.complete, "example ") +]] local expect = require "cc.expect".expect local completion = require "cc.completion" @@ -69,37 +82,29 @@ local function program(shell, text) return shell.completeProgram(text) end ---- A helper function for building shell completion arguments. --- --- This accepts a series of single-argument completion functions, and combines --- them into a function suitable for use with @{shell.setCompletionFunction}. --- --- @tparam nil|table|function ... Every argument to @{build} represents an argument --- to the program you wish to complete. Each argument can be one of three types: --- --- - `nil`: This argument will not be completed. --- --- - A function: This argument will be completed with the given function. It is --- called with the @{shell} object, the string to complete and the arguments --- before this one. --- --- - A table: This acts as a more powerful version of the function case. The table --- must have a function as the first item - this will be called with the shell, --- string and preceding arguments as above, but also followed by any additional --- items in the table. This provides a more convenient interface to pass --- options to your completion functions. --- --- If this table is the last argument, it may also set the `many` key to true, --- which states this function should be used to complete any remaining arguments. --- --- @usage Prompt for a choice of options, followed by a directory, and then multiple --- files. --- --- complete.build( --- { complete.choice, { "get", "put" } }, --- complete.dir, --- { complete.file, many = true } --- ) +--[[- A helper function for building shell completion arguments. + +This accepts a series of single-argument completion functions, and combines +them into a function suitable for use with @{shell.setCompletionFunction}. + +@tparam nil|table|function ... Every argument to @{build} represents an argument +to the program you wish to complete. Each argument can be one of three types: + + - `nil`: This argument will not be completed. + + - A function: This argument will be completed with the given function. It is + called with the @{shell} object, the string to complete and the arguments + before this one. + + - A table: This acts as a more powerful version of the function case. The table + must have a function as the first item - this will be called with the shell, + string and preceding arguments as above, but also followed by any additional + items in the table. This provides a more convenient interface to pass + options to your completion functions. + + If this table is the last argument, it may also set the `many` key to true, + which states this function should be used to complete any remaining arguments. +]] local function build(...) local arguments = table.pack(...) for i = 1, arguments.n do From c35707725f1441e9870bda820d5de04edf2033ee Mon Sep 17 00:00:00 2001 From: SquidDev Date: Fri, 20 Nov 2020 21:59:17 +0000 Subject: [PATCH 10/38] More examples Yay! --- rollup.config.js | 12 ++- .../computercraft/lua/rom/apis/paintutils.lua | 7 ++ .../computercraft/lua/rom/apis/parallel.lua | 83 +++++++++++++------ .../lua/rom/programs/fun/advanced/paint.lua | 4 +- src/web/index.tsx | 5 ++ src/web/mount/example.nfp | 16 ++++ 6 files changed, 97 insertions(+), 30 deletions(-) create mode 100644 src/web/mount/example.nfp diff --git a/rollup.config.js b/rollup.config.js index 1e0342fea..725abb7ca 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -35,14 +35,20 @@ export default { await Promise.all(files .filter(x => path.extname(x) !== ".ts") - .map(file => fs.writeFile(`${input}/mount/${file}.d.ts`, template)) + .map(async file => { + const path = `${input}/mount/${file}.d.ts`; + const contents = await fs.readFile(path, { encoding: "utf-8" }).catch(() => ""); + if (contents !== template) await fs.writeFile(path, template); + }) ); return options; }, async transform(code, file) { // Allow loading files in /mount. - if (path.extname(file) != ".lua" && path.basename(file) != ".settings") return null; - return `export default ${JSON.stringify(code)};\n`; + const ext = path.extname(file); + return ext != '.tsx' && ext != '.ts' && path.dirname(file) === path.resolve(`${input}/mount`) + ? `export default ${JSON.stringify(code)};\n` + : null; }, } ], diff --git a/src/main/resources/data/computercraft/lua/rom/apis/paintutils.lua b/src/main/resources/data/computercraft/lua/rom/apis/paintutils.lua index 7ae1006b8..b920341c3 100644 --- a/src/main/resources/data/computercraft/lua/rom/apis/paintutils.lua +++ b/src/main/resources/data/computercraft/lua/rom/apis/paintutils.lua @@ -64,6 +64,10 @@ end -- -- @treturn table|nil The parsed image data, suitable for use with -- @{paintutils.drawImage}, or `nil` if the file does not exist. +-- @usage Load an image and draw it. +-- +-- local image = paintutils.loadImage("test-image.nfp") +-- paintutils.drawImage(image, term.getCursorPos()) function loadImage(path) expect(1, path, "string") @@ -107,6 +111,7 @@ end -- @tparam number endY The end y position of the line. -- @tparam[opt] number colour The @{colors|color} of this pixel. This will be -- the current background colour if not specified. +-- @usage paintutils.drawLine(2, 3, 30, 7, colors.red) function drawLine(startX, startY, endX, endY, colour) expect(1, startX, "number") expect(2, startY, "number") @@ -170,6 +175,7 @@ end -- @tparam number endY The end y position of the line. -- @tparam[opt] number colour The @{colors|color} of this pixel. This will be -- the current background colour if not specified. +-- @usage paintutils.drawBox(2, 3, 30, 7, colors.red) function drawBox(startX, startY, endX, endY, nColour) expect(1, startX, "number") expect(2, startY, "number") @@ -222,6 +228,7 @@ end -- @tparam number endY The end y position of the line. -- @tparam[opt] number colour The @{colors|color} of this pixel. This will be -- the current background colour if not specified. +-- @usage paintutils.drawFilledBox(2, 3, 30, 7, colors.red) function drawFilledBox(startX, startY, endX, endY, nColour) expect(1, startX, "number") expect(2, startY, "number") diff --git a/src/main/resources/data/computercraft/lua/rom/apis/parallel.lua b/src/main/resources/data/computercraft/lua/rom/apis/parallel.lua index c787eff41..e826ed28e 100644 --- a/src/main/resources/data/computercraft/lua/rom/apis/parallel.lua +++ b/src/main/resources/data/computercraft/lua/rom/apis/parallel.lua @@ -1,18 +1,19 @@ ---- Provides a simple implementation of multitasking. --- --- Functions are not actually executed simultaniously, but rather this API will --- automatically switch between them whenever they yield (eg whenever they call --- @{coroutine.yield}, or functions that call that - eg `os.pullEvent` - or --- functions that call that, etc - basically, anything that causes the function --- to "pause"). --- --- Each function executed in "parallel" gets its own copy of the event queue, --- and so "event consuming" functions (again, mostly anything that causes the --- script to pause - eg `sleep`, `rednet.receive`, most of the `turtle` API, --- etc) can safely be used in one without affecting the event queue accessed by --- the other. --- --- @module parallel +--[[- Provides a simple implementation of multitasking. + +Functions are not actually executed simultaniously, but rather this API will +automatically switch between them whenever they yield (eg whenever they call +@{coroutine.yield}, or functions that call that - eg `os.pullEvent` - or +functions that call that, etc - basically, anything that causes the function +to "pause"). + +Each function executed in "parallel" gets its own copy of the event queue, +and so "event consuming" functions (again, mostly anything that causes the +script to pause - eg `sleep`, `rednet.receive`, most of the `turtle` API, +etc) can safely be used in one without affecting the event queue accessed by +the other. + +@module parallel +]] local function create(...) local tFns = table.pack(...) @@ -70,21 +71,53 @@ local function runUntilLimit(_routines, _limit) end end ---- Switches between execution of the functions, until any of them --- finishes. If any of the functions errors, the message is propagated upwards --- from the @{parallel.waitForAny} call. --- --- @tparam function ... The functions this task will run +--[[- Switches between execution of the functions, until any of them +finishes. If any of the functions errors, the message is propagated upwards +from the @{parallel.waitForAny} call. + +@tparam function ... The functions this task will run +@usage Print a message every second until the `q` key is pressed. + + local function tick() + while true do + os.sleep(1) + print("Tick") + end + end + local function wait_for_q() + repeat + local _, key = os.pullEvent("key") + until key == keys.q + print("Q was pressed!") + end + + parallel.waitForAny(tick, wait_for_q) + print("Everything done!") +]] function waitForAny(...) local routines = create(...) return runUntilLimit(routines, #routines - 1) end ---- Switches between execution of the functions, until all of them are --- finished. If any of the functions errors, the message is propagated upwards --- from the @{parallel.waitForAll} call. --- --- @tparam function ... The functions this task will run +--[[- Switches between execution of the functions, until all of them are +finished. If any of the functions errors, the message is propagated upwards +from the @{parallel.waitForAll} call. + +@tparam function ... The functions this task will run +@usage Start off two timers and wait for them both to run. + + local function a() + os.sleep(1) + print("A is done") + end + local function b() + os.sleep(3) + print("B is done") + end + + parallel.waitForAll(a, b) + print("Everything done!") +]] function waitForAll(...) local routines = create(...) return runUntilLimit(routines, 0) diff --git a/src/main/resources/data/computercraft/lua/rom/programs/fun/advanced/paint.lua b/src/main/resources/data/computercraft/lua/rom/programs/fun/advanced/paint.lua index cab2cfc6c..862bc2afe 100644 --- a/src/main/resources/data/computercraft/lua/rom/programs/fun/advanced/paint.lua +++ b/src/main/resources/data/computercraft/lua/rom/programs/fun/advanced/paint.lua @@ -252,8 +252,8 @@ local function drawCanvasLine(y) bg = bg .. color_hex_lookup[pixel or canvasColour] else text = text .. "\127" - fg = fg .. color_hex_lookup[canvasColour] - bg = bg .. color_hex_lookup[colours.grey] + fg = fg .. color_hex_lookup[colours.grey] + bg = bg .. color_hex_lookup[canvasColour] end end diff --git a/src/web/index.tsx b/src/web/index.tsx index 0bf476a86..f4e85033a 100644 --- a/src/web/index.tsx +++ b/src/web/index.tsx @@ -4,10 +4,15 @@ import type { ComponentChild } from "preact"; import settingsFile from "./mount/.settings"; import startupFile from "./mount/startup.lua"; import exprTemplate from "./mount/expr_template.lua"; +import exampleImage from "./mount/example.nfp"; const defaultFiles: { [filename: string]: string } = { ".settings": settingsFile, "startup.lua": startupFile, + + // TODO: Ideally this'd be in data/image.nfp or something, but copy-cat's + // dir bootstrapping doesn't cope with that right now. + "test-image.nfp": exampleImage }; const clamp = (value: number, min: number, max: number): number => { diff --git a/src/web/mount/example.nfp b/src/web/mount/example.nfp new file mode 100644 index 000000000..1025172c9 --- /dev/null +++ b/src/web/mount/example.nfp @@ -0,0 +1,16 @@ +fffffffffffffffffffffff +f444444444444444444444f +f444444444444444444444f +f44fffffffffffffffff44f +f44ff0ffffffffffffff44f +f44fff0fffffffffffff44f +f44ff0ffffffffffffff44f +f44fffffffffffffffff44f +f44fffffffffffffffff44f +f44fffffffffffffffff44f +f44fffffffffffffffff44f +f44fffffffffffffffff44f +f444444444444444444444f +f4444444444444444fff44f +f444444444444444444444f +fffffffffffffffffffffff From 9a749642d294506095e697a3a4345dfe260bd68c Mon Sep 17 00:00:00 2001 From: Lupus590 Date: Sat, 21 Nov 2020 12:11:40 +0000 Subject: [PATCH 11/38] Strict Globals (#583) --- .../resources/data/computercraft/lua/bios.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/resources/data/computercraft/lua/bios.lua b/src/main/resources/data/computercraft/lua/bios.lua index 4573f9826..f8e21f941 100644 --- a/src/main/resources/data/computercraft/lua/bios.lua +++ b/src/main/resources/data/computercraft/lua/bios.lua @@ -523,6 +523,16 @@ function os.run(_tEnv, _sPath, ...) local tEnv = _tEnv setmetatable(tEnv, { __index = _G }) + + if settings.get("bios.strict_globals", false) then + -- load will attempt to set _ENV on this environment, which + -- throws an error with this protection enabled. Thus we set it here first. + tEnv._ENV = tEnv + getmetatable(tEnv).__newindex = function(_, name) + error("Attempt to create global " .. tostring(name), 2) + end + end + local fnFile, err = loadfile(_sPath, nil, tEnv) if fnFile then local ok, err = pcall(fnFile, ...) @@ -954,6 +964,11 @@ settings.define("lua.function_source", { description = "Show where a function was defined when printing functions.", type = "boolean", }) +settings.define("bios.strict_globals", { + default = false, + description = "Prevents assigning variables into a program's environment. Make sure you use the local keyword or assign to _G explicitly.", + type = "boolean", +}) if term.isColour() then settings.define("bios.use_multishell", { From fff8353451451be5ae31e0f63d8e529b127fd186 Mon Sep 17 00:00:00 2001 From: Lupus590 Date: Sat, 21 Nov 2020 12:25:19 +0000 Subject: [PATCH 12/38] Remove extra space (#586) --- src/main/resources/data/computercraft/lua/bios.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/data/computercraft/lua/bios.lua b/src/main/resources/data/computercraft/lua/bios.lua index f8e21f941..4407dc99e 100644 --- a/src/main/resources/data/computercraft/lua/bios.lua +++ b/src/main/resources/data/computercraft/lua/bios.lua @@ -524,7 +524,7 @@ function os.run(_tEnv, _sPath, ...) local tEnv = _tEnv setmetatable(tEnv, { __index = _G }) - if settings.get("bios.strict_globals", false) then + if settings.get("bios.strict_globals", false) then -- load will attempt to set _ENV on this environment, which -- throws an error with this protection enabled. Thus we set it here first. tEnv._ENV = tEnv From 486f41f08286ddcfad91d72b83a9361bd9c215cb Mon Sep 17 00:00:00 2001 From: JackMacWindows Date: Thu, 26 Nov 2020 14:46:03 -0500 Subject: [PATCH 13/38] Fixed length check on function name in `expect` (#589) --- .../data/computercraft/lua/rom/modules/main/cc/expect.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/data/computercraft/lua/rom/modules/main/cc/expect.lua b/src/main/resources/data/computercraft/lua/rom/modules/main/cc/expect.lua index 397be085e..6be4e135d 100644 --- a/src/main/resources/data/computercraft/lua/rom/modules/main/cc/expect.lua +++ b/src/main/resources/data/computercraft/lua/rom/modules/main/cc/expect.lua @@ -53,7 +53,7 @@ local function expect(index, value, ...) local name if native_type(debug) == "table" and native_type(debug.getinfo) == "function" then local ok, info = pcall(debug.getinfo, 3, "nS") - if ok and info.name and #info.name ~= "" and info.what ~= "C" then name = info.name end + if ok and info.name and info.name ~= "" and info.what ~= "C" then name = info.name end end local type_names = get_type_names(...) From 04f9644ae75dafc72da4c4790f334d2e90b03e6f Mon Sep 17 00:00:00 2001 From: SquidDev Date: Fri, 27 Nov 2020 21:29:11 +0000 Subject: [PATCH 14/38] Allow strings or numbers in textutils.*tabulate A little dubious, but apparently CC used to support it. This means we're consistent with methods like io.write or string.len which accept strings or numbers. Fixes #591 --- .../data/computercraft/lua/rom/apis/textutils.lua | 7 ++++--- src/test/resources/test-rom/spec/apis/textutils_spec.lua | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/resources/data/computercraft/lua/rom/apis/textutils.lua b/src/main/resources/data/computercraft/lua/rom/apis/textutils.lua index ec0633589..30766e8ec 100644 --- a/src/main/resources/data/computercraft/lua/rom/apis/textutils.lua +++ b/src/main/resources/data/computercraft/lua/rom/apis/textutils.lua @@ -163,10 +163,11 @@ local function tabulateCommon(bPaged, ...) for n, t in ipairs(tAll) do if type(t) == "table" then for nu, sItem in pairs(t) do - if type(sItem) ~= "string" then - error("bad argument #" .. n .. "." .. nu .. " (expected string, got " .. type(sItem) .. ")", 3) + local ty = type(sItem) + if ty ~= "string" and ty ~= "number" then + error("bad argument #" .. n .. "." .. nu .. " (expected string, got " .. ty .. ")", 3) end - nMaxLen = math.max(#sItem + 1, nMaxLen) + nMaxLen = math.max(#tostring(sItem) + 1, nMaxLen) end end end diff --git a/src/test/resources/test-rom/spec/apis/textutils_spec.lua b/src/test/resources/test-rom/spec/apis/textutils_spec.lua index 486bf6118..6db7917ea 100644 --- a/src/test/resources/test-rom/spec/apis/textutils_spec.lua +++ b/src/test/resources/test-rom/spec/apis/textutils_spec.lua @@ -33,11 +33,12 @@ describe("The textutils library", function() term.redirect(window.create(term.current(), 1, 1, 5, 5, false)) textutils.tabulate() - textutils.tabulate({ "test" }) + textutils.tabulate({ "test", 1 }) textutils.tabulate(colors.white) expect.error(textutils.tabulate, nil):eq("bad argument #1 (expected number or table, got nil)") expect.error(textutils.tabulate, { "test" }, nil):eq("bad argument #2 (expected number or table, got nil)") + expect.error(textutils.tabulate, { false }):eq("bad argument #1.1 (expected string, got boolean)") end) end) From d4199064ae5ae8023c589f80f12d94e1c6bbc2b5 Mon Sep 17 00:00:00 2001 From: SquidDev Date: Sat, 28 Nov 2020 11:41:03 +0000 Subject: [PATCH 15/38] Make fs.combine accept multiple arguments Means we can now do fs.combine("a", "b", "c"). Of course, one may just write "a/b/c" in this case, but it's definitely useful elsewhere. This is /technically/ a breaking change as fs.combine(a, b:gsub(...)) will no longer function (as gsub returns multiple arguments). However, I've done a quick search through GH and my Pastebin archives and can't find any programs which would break. Fingers crossed. --- .../dan200/computercraft/core/apis/FSAPI.java | 24 ++++++++++++++----- .../core/filesystem/FileSystem.java | 4 ++-- .../resources/test-rom/spec/apis/fs_spec.lua | 18 ++++++++------ 3 files changed, 31 insertions(+), 15 deletions(-) diff --git a/src/main/java/dan200/computercraft/core/apis/FSAPI.java b/src/main/java/dan200/computercraft/core/apis/FSAPI.java index 4f122ae4c..34a2e0f4c 100644 --- a/src/main/java/dan200/computercraft/core/apis/FSAPI.java +++ b/src/main/java/dan200/computercraft/core/apis/FSAPI.java @@ -5,6 +5,7 @@ */ package dan200.computercraft.core.apis; +import dan200.computercraft.api.lua.IArguments; import dan200.computercraft.api.lua.ILuaAPI; import dan200.computercraft.api.lua.LuaException; import dan200.computercraft.api.lua.LuaFunction; @@ -83,17 +84,28 @@ public class FSAPI implements ILuaAPI } /** - * Combines two parts of a path into one full path, adding separators as + * Combines several parts of a path into one full path, adding separators as * needed. * - * @param pathA The first part of the path. For example, a parent directory path. - * @param pathB The second part of the path. For example, a file name. + * @param arguments The paths to combine. * @return The new path, with separators added between parts as needed. + * @cc.tparam string path The first part of the path. For example, a parent directory path. + * @cc.tparam string ... Additional parts of the path to combine. */ @LuaFunction - public final String combine( String pathA, String pathB ) + public final String combine( IArguments arguments ) throws LuaException { - return fileSystem.combine( pathA, pathB ); + StringBuilder result = new StringBuilder(); + result.append( FileSystem.sanitizePath( arguments.getString( 0 ), true ) ); + + for( int i = 1, n = arguments.count(); i < n; i++ ) + { + String part = FileSystem.sanitizePath( arguments.getString( i ), true ); + if( result.length() != 0 && !part.isEmpty() ) result.append( '/' ); + result.append( part ); + } + + return FileSystem.sanitizePath( result.toString(), true ); } /** @@ -385,8 +397,8 @@ public class FSAPI implements ILuaAPI * * @param path The path to check the free space for. * @return The amount of free space available, in bytes. - * @cc.treturn number|"unlimited" The amount of free space available, in bytes, or "unlimited". * @throws LuaException If the path doesn't exist. + * @cc.treturn number|"unlimited" The amount of free space available, in bytes, or "unlimited". */ @LuaFunction public final Object getFreeSpace( String path ) throws LuaException diff --git a/src/main/java/dan200/computercraft/core/filesystem/FileSystem.java b/src/main/java/dan200/computercraft/core/filesystem/FileSystem.java index 644515e1c..bb6c7149c 100644 --- a/src/main/java/dan200/computercraft/core/filesystem/FileSystem.java +++ b/src/main/java/dan200/computercraft/core/filesystem/FileSystem.java @@ -98,7 +98,7 @@ public class FileSystem mounts.remove( sanitizePath( path ) ); } - public synchronized String combine( String path, String childPath ) + public String combine( String path, String childPath ) { path = sanitizePath( path, true ); childPath = sanitizePath( childPath, true ); @@ -479,7 +479,7 @@ public class FileSystem private static final Pattern threeDotsPattern = Pattern.compile( "^\\.{3,}$" ); - private static String sanitizePath( String path, boolean allowWildcards ) + public static String sanitizePath( String path, boolean allowWildcards ) { // Allow windowsy slashes path = path.replace( '\\', '/' ); diff --git a/src/test/resources/test-rom/spec/apis/fs_spec.lua b/src/test/resources/test-rom/spec/apis/fs_spec.lua index 58db9e566..9a861af34 100644 --- a/src/test/resources/test-rom/spec/apis/fs_spec.lua +++ b/src/test/resources/test-rom/spec/apis/fs_spec.lua @@ -39,15 +39,19 @@ describe("The fs library", function() end) end) - describe("fs.list", function() - it("fails on files", function() - expect.error(fs.list, "rom/startup.lua"):eq("/rom/startup.lua: Not a directory") - expect.error(fs.list, "startup.lua"):eq("/startup.lua: Not a directory") + describe("fs.combine", function() + it("removes . and ..", function() + expect(fs.combine("./a/b")):eq("a/b") + expect(fs.combine("a/b", "../c")):eq("a/c") + expect(fs.combine("a", "../c")):eq("c") + expect(fs.combine("a", "../../c")):eq("../c") end) - it("fails on non-existent nodes", function() - expect.error(fs.list, "rom/x"):eq("/rom/x: Not a directory") - expect.error(fs.list, "x"):eq("/x: Not a directory") + it("combines empty paths", function() + expect(fs.combine("a")):eq("a") + expect(fs.combine("a", "")):eq("a") + expect(fs.combine("", "a")):eq("a") + expect(fs.combine("a", "", "b", "c")):eq("a/b/c") end) end) From 6734a0e112c29541bc6611cc26c18874ec7a4c18 Mon Sep 17 00:00:00 2001 From: SquidDev Date: Sat, 28 Nov 2020 12:06:25 +0000 Subject: [PATCH 16/38] Also generate computer models I'm getting quite addicted to this. Maybe less savings than monitors, but still worth doing due to the number of files created. Also fix our angle calculations for monitors. Thankfully we hadn't shipped this yet :). --- .../blockstates/computer_advanced.json | 49 +++++ .../blockstates/computer_command.json | 49 +++++ .../blockstates/computer_normal.json | 49 +++++ .../blockstates/monitor_advanced.json | 192 +++++++++--------- .../blockstates/monitor_normal.json | 192 +++++++++--------- .../block/computer_advanced_blinking.json | 8 + .../models/block/computer_advanced_off.json | 8 + .../models/block/computer_advanced_on.json | 8 + .../block/computer_command_blinking.json | 8 + .../models/block/computer_command_off.json | 8 + .../models/block/computer_command_on.json | 8 + .../block/computer_normal_blinking.json | 8 + .../models/block/computer_normal_off.json | 8 + .../models/block/computer_normal_on.json | 8 + .../data/BlockModelProvider.java | 70 ++++++- .../blockstates/computer_advanced.json | 18 -- .../blockstates/computer_command.json | 19 -- .../blockstates/computer_normal.json | 18 -- .../block/computer_advanced_blinking.json | 8 - .../models/block/computer_advanced_off.json | 8 - .../models/block/computer_advanced_on.json | 8 - .../block/computer_command_blinking.json | 8 - .../models/block/computer_command_off.json | 8 - .../models/block/computer_command_on.json | 8 - .../block/computer_normal_blinking.json | 8 - .../models/block/computer_normal_off.json | 8 - .../models/block/computer_normal_on.json | 8 - 27 files changed, 473 insertions(+), 327 deletions(-) create mode 100644 src/generated/resources/assets/computercraft/blockstates/computer_advanced.json create mode 100644 src/generated/resources/assets/computercraft/blockstates/computer_command.json create mode 100644 src/generated/resources/assets/computercraft/blockstates/computer_normal.json create mode 100644 src/generated/resources/assets/computercraft/models/block/computer_advanced_blinking.json create mode 100644 src/generated/resources/assets/computercraft/models/block/computer_advanced_off.json create mode 100644 src/generated/resources/assets/computercraft/models/block/computer_advanced_on.json create mode 100644 src/generated/resources/assets/computercraft/models/block/computer_command_blinking.json create mode 100644 src/generated/resources/assets/computercraft/models/block/computer_command_off.json create mode 100644 src/generated/resources/assets/computercraft/models/block/computer_command_on.json create mode 100644 src/generated/resources/assets/computercraft/models/block/computer_normal_blinking.json create mode 100644 src/generated/resources/assets/computercraft/models/block/computer_normal_off.json create mode 100644 src/generated/resources/assets/computercraft/models/block/computer_normal_on.json delete mode 100644 src/main/resources/assets/computercraft/blockstates/computer_advanced.json delete mode 100644 src/main/resources/assets/computercraft/blockstates/computer_command.json delete mode 100644 src/main/resources/assets/computercraft/blockstates/computer_normal.json delete mode 100644 src/main/resources/assets/computercraft/models/block/computer_advanced_blinking.json delete mode 100644 src/main/resources/assets/computercraft/models/block/computer_advanced_off.json delete mode 100644 src/main/resources/assets/computercraft/models/block/computer_advanced_on.json delete mode 100644 src/main/resources/assets/computercraft/models/block/computer_command_blinking.json delete mode 100644 src/main/resources/assets/computercraft/models/block/computer_command_off.json delete mode 100644 src/main/resources/assets/computercraft/models/block/computer_command_on.json delete mode 100644 src/main/resources/assets/computercraft/models/block/computer_normal_blinking.json delete mode 100644 src/main/resources/assets/computercraft/models/block/computer_normal_off.json delete mode 100644 src/main/resources/assets/computercraft/models/block/computer_normal_on.json diff --git a/src/generated/resources/assets/computercraft/blockstates/computer_advanced.json b/src/generated/resources/assets/computercraft/blockstates/computer_advanced.json new file mode 100644 index 000000000..ca62effa6 --- /dev/null +++ b/src/generated/resources/assets/computercraft/blockstates/computer_advanced.json @@ -0,0 +1,49 @@ +{ + "variants": { + "facing=north,state=off": { + "model": "computercraft:block/computer_advanced_off" + }, + "facing=south,state=off": { + "model": "computercraft:block/computer_advanced_off", + "y": 180 + }, + "facing=west,state=off": { + "model": "computercraft:block/computer_advanced_off", + "y": 270 + }, + "facing=east,state=off": { + "model": "computercraft:block/computer_advanced_off", + "y": 90 + }, + "facing=north,state=on": { + "model": "computercraft:block/computer_advanced_on" + }, + "facing=south,state=on": { + "model": "computercraft:block/computer_advanced_on", + "y": 180 + }, + "facing=west,state=on": { + "model": "computercraft:block/computer_advanced_on", + "y": 270 + }, + "facing=east,state=on": { + "model": "computercraft:block/computer_advanced_on", + "y": 90 + }, + "facing=north,state=blinking": { + "model": "computercraft:block/computer_advanced_blinking" + }, + "facing=south,state=blinking": { + "model": "computercraft:block/computer_advanced_blinking", + "y": 180 + }, + "facing=west,state=blinking": { + "model": "computercraft:block/computer_advanced_blinking", + "y": 270 + }, + "facing=east,state=blinking": { + "model": "computercraft:block/computer_advanced_blinking", + "y": 90 + } + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/computercraft/blockstates/computer_command.json b/src/generated/resources/assets/computercraft/blockstates/computer_command.json new file mode 100644 index 000000000..d0580539a --- /dev/null +++ b/src/generated/resources/assets/computercraft/blockstates/computer_command.json @@ -0,0 +1,49 @@ +{ + "variants": { + "facing=north,state=off": { + "model": "computercraft:block/computer_command_off" + }, + "facing=south,state=off": { + "model": "computercraft:block/computer_command_off", + "y": 180 + }, + "facing=west,state=off": { + "model": "computercraft:block/computer_command_off", + "y": 270 + }, + "facing=east,state=off": { + "model": "computercraft:block/computer_command_off", + "y": 90 + }, + "facing=north,state=on": { + "model": "computercraft:block/computer_command_on" + }, + "facing=south,state=on": { + "model": "computercraft:block/computer_command_on", + "y": 180 + }, + "facing=west,state=on": { + "model": "computercraft:block/computer_command_on", + "y": 270 + }, + "facing=east,state=on": { + "model": "computercraft:block/computer_command_on", + "y": 90 + }, + "facing=north,state=blinking": { + "model": "computercraft:block/computer_command_blinking" + }, + "facing=south,state=blinking": { + "model": "computercraft:block/computer_command_blinking", + "y": 180 + }, + "facing=west,state=blinking": { + "model": "computercraft:block/computer_command_blinking", + "y": 270 + }, + "facing=east,state=blinking": { + "model": "computercraft:block/computer_command_blinking", + "y": 90 + } + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/computercraft/blockstates/computer_normal.json b/src/generated/resources/assets/computercraft/blockstates/computer_normal.json new file mode 100644 index 000000000..4108d0aa9 --- /dev/null +++ b/src/generated/resources/assets/computercraft/blockstates/computer_normal.json @@ -0,0 +1,49 @@ +{ + "variants": { + "facing=north,state=off": { + "model": "computercraft:block/computer_normal_off" + }, + "facing=south,state=off": { + "model": "computercraft:block/computer_normal_off", + "y": 180 + }, + "facing=west,state=off": { + "model": "computercraft:block/computer_normal_off", + "y": 270 + }, + "facing=east,state=off": { + "model": "computercraft:block/computer_normal_off", + "y": 90 + }, + "facing=north,state=on": { + "model": "computercraft:block/computer_normal_on" + }, + "facing=south,state=on": { + "model": "computercraft:block/computer_normal_on", + "y": 180 + }, + "facing=west,state=on": { + "model": "computercraft:block/computer_normal_on", + "y": 270 + }, + "facing=east,state=on": { + "model": "computercraft:block/computer_normal_on", + "y": 90 + }, + "facing=north,state=blinking": { + "model": "computercraft:block/computer_normal_blinking" + }, + "facing=south,state=blinking": { + "model": "computercraft:block/computer_normal_blinking", + "y": 180 + }, + "facing=west,state=blinking": { + "model": "computercraft:block/computer_normal_blinking", + "y": 270 + }, + "facing=east,state=blinking": { + "model": "computercraft:block/computer_normal_blinking", + "y": 90 + } + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/computercraft/blockstates/monitor_advanced.json b/src/generated/resources/assets/computercraft/blockstates/monitor_advanced.json index 978e3ed95..230c2c727 100644 --- a/src/generated/resources/assets/computercraft/blockstates/monitor_advanced.json +++ b/src/generated/resources/assets/computercraft/blockstates/monitor_advanced.json @@ -12,12 +12,12 @@ "facing=west,orientation=down,state=none": { "model": "computercraft:block/monitor_advanced", "x": 90, - "y": 90 + "y": 270 }, "facing=east,orientation=down,state=none": { "model": "computercraft:block/monitor_advanced", "x": 90, - "y": -90 + "y": 90 }, "facing=north,orientation=up,state=none": { "model": "computercraft:block/monitor_advanced", @@ -31,12 +31,12 @@ "facing=west,orientation=up,state=none": { "model": "computercraft:block/monitor_advanced", "x": 270, - "y": 90 + "y": 270 }, "facing=east,orientation=up,state=none": { "model": "computercraft:block/monitor_advanced", "x": 270, - "y": -90 + "y": 90 }, "facing=north,orientation=north,state=none": { "model": "computercraft:block/monitor_advanced" @@ -47,11 +47,11 @@ }, "facing=west,orientation=north,state=none": { "model": "computercraft:block/monitor_advanced", - "y": 90 + "y": 270 }, "facing=east,orientation=north,state=none": { "model": "computercraft:block/monitor_advanced", - "y": -90 + "y": 90 }, "facing=north,orientation=down,state=l": { "model": "computercraft:block/monitor_advanced_l", @@ -65,12 +65,12 @@ "facing=west,orientation=down,state=l": { "model": "computercraft:block/monitor_advanced_l", "x": 90, - "y": 90 + "y": 270 }, "facing=east,orientation=down,state=l": { "model": "computercraft:block/monitor_advanced_l", "x": 90, - "y": -90 + "y": 90 }, "facing=north,orientation=up,state=l": { "model": "computercraft:block/monitor_advanced_l", @@ -84,12 +84,12 @@ "facing=west,orientation=up,state=l": { "model": "computercraft:block/monitor_advanced_l", "x": 270, - "y": 90 + "y": 270 }, "facing=east,orientation=up,state=l": { "model": "computercraft:block/monitor_advanced_l", "x": 270, - "y": -90 + "y": 90 }, "facing=north,orientation=north,state=l": { "model": "computercraft:block/monitor_advanced_l" @@ -100,11 +100,11 @@ }, "facing=west,orientation=north,state=l": { "model": "computercraft:block/monitor_advanced_l", - "y": 90 + "y": 270 }, "facing=east,orientation=north,state=l": { "model": "computercraft:block/monitor_advanced_l", - "y": -90 + "y": 90 }, "facing=north,orientation=down,state=r": { "model": "computercraft:block/monitor_advanced_r", @@ -118,12 +118,12 @@ "facing=west,orientation=down,state=r": { "model": "computercraft:block/monitor_advanced_r", "x": 90, - "y": 90 + "y": 270 }, "facing=east,orientation=down,state=r": { "model": "computercraft:block/monitor_advanced_r", "x": 90, - "y": -90 + "y": 90 }, "facing=north,orientation=up,state=r": { "model": "computercraft:block/monitor_advanced_r", @@ -137,12 +137,12 @@ "facing=west,orientation=up,state=r": { "model": "computercraft:block/monitor_advanced_r", "x": 270, - "y": 90 + "y": 270 }, "facing=east,orientation=up,state=r": { "model": "computercraft:block/monitor_advanced_r", "x": 270, - "y": -90 + "y": 90 }, "facing=north,orientation=north,state=r": { "model": "computercraft:block/monitor_advanced_r" @@ -153,11 +153,11 @@ }, "facing=west,orientation=north,state=r": { "model": "computercraft:block/monitor_advanced_r", - "y": 90 + "y": 270 }, "facing=east,orientation=north,state=r": { "model": "computercraft:block/monitor_advanced_r", - "y": -90 + "y": 90 }, "facing=north,orientation=down,state=lr": { "model": "computercraft:block/monitor_advanced_lr", @@ -171,12 +171,12 @@ "facing=west,orientation=down,state=lr": { "model": "computercraft:block/monitor_advanced_lr", "x": 90, - "y": 90 + "y": 270 }, "facing=east,orientation=down,state=lr": { "model": "computercraft:block/monitor_advanced_lr", "x": 90, - "y": -90 + "y": 90 }, "facing=north,orientation=up,state=lr": { "model": "computercraft:block/monitor_advanced_lr", @@ -190,12 +190,12 @@ "facing=west,orientation=up,state=lr": { "model": "computercraft:block/monitor_advanced_lr", "x": 270, - "y": 90 + "y": 270 }, "facing=east,orientation=up,state=lr": { "model": "computercraft:block/monitor_advanced_lr", "x": 270, - "y": -90 + "y": 90 }, "facing=north,orientation=north,state=lr": { "model": "computercraft:block/monitor_advanced_lr" @@ -206,11 +206,11 @@ }, "facing=west,orientation=north,state=lr": { "model": "computercraft:block/monitor_advanced_lr", - "y": 90 + "y": 270 }, "facing=east,orientation=north,state=lr": { "model": "computercraft:block/monitor_advanced_lr", - "y": -90 + "y": 90 }, "facing=north,orientation=down,state=u": { "model": "computercraft:block/monitor_advanced_u", @@ -224,12 +224,12 @@ "facing=west,orientation=down,state=u": { "model": "computercraft:block/monitor_advanced_u", "x": 90, - "y": 90 + "y": 270 }, "facing=east,orientation=down,state=u": { "model": "computercraft:block/monitor_advanced_u", "x": 90, - "y": -90 + "y": 90 }, "facing=north,orientation=up,state=u": { "model": "computercraft:block/monitor_advanced_u", @@ -243,12 +243,12 @@ "facing=west,orientation=up,state=u": { "model": "computercraft:block/monitor_advanced_u", "x": 270, - "y": 90 + "y": 270 }, "facing=east,orientation=up,state=u": { "model": "computercraft:block/monitor_advanced_u", "x": 270, - "y": -90 + "y": 90 }, "facing=north,orientation=north,state=u": { "model": "computercraft:block/monitor_advanced_u" @@ -259,11 +259,11 @@ }, "facing=west,orientation=north,state=u": { "model": "computercraft:block/monitor_advanced_u", - "y": 90 + "y": 270 }, "facing=east,orientation=north,state=u": { "model": "computercraft:block/monitor_advanced_u", - "y": -90 + "y": 90 }, "facing=north,orientation=down,state=d": { "model": "computercraft:block/monitor_advanced_d", @@ -277,12 +277,12 @@ "facing=west,orientation=down,state=d": { "model": "computercraft:block/monitor_advanced_d", "x": 90, - "y": 90 + "y": 270 }, "facing=east,orientation=down,state=d": { "model": "computercraft:block/monitor_advanced_d", "x": 90, - "y": -90 + "y": 90 }, "facing=north,orientation=up,state=d": { "model": "computercraft:block/monitor_advanced_d", @@ -296,12 +296,12 @@ "facing=west,orientation=up,state=d": { "model": "computercraft:block/monitor_advanced_d", "x": 270, - "y": 90 + "y": 270 }, "facing=east,orientation=up,state=d": { "model": "computercraft:block/monitor_advanced_d", "x": 270, - "y": -90 + "y": 90 }, "facing=north,orientation=north,state=d": { "model": "computercraft:block/monitor_advanced_d" @@ -312,11 +312,11 @@ }, "facing=west,orientation=north,state=d": { "model": "computercraft:block/monitor_advanced_d", - "y": 90 + "y": 270 }, "facing=east,orientation=north,state=d": { "model": "computercraft:block/monitor_advanced_d", - "y": -90 + "y": 90 }, "facing=north,orientation=down,state=ud": { "model": "computercraft:block/monitor_advanced_ud", @@ -330,12 +330,12 @@ "facing=west,orientation=down,state=ud": { "model": "computercraft:block/monitor_advanced_ud", "x": 90, - "y": 90 + "y": 270 }, "facing=east,orientation=down,state=ud": { "model": "computercraft:block/monitor_advanced_ud", "x": 90, - "y": -90 + "y": 90 }, "facing=north,orientation=up,state=ud": { "model": "computercraft:block/monitor_advanced_ud", @@ -349,12 +349,12 @@ "facing=west,orientation=up,state=ud": { "model": "computercraft:block/monitor_advanced_ud", "x": 270, - "y": 90 + "y": 270 }, "facing=east,orientation=up,state=ud": { "model": "computercraft:block/monitor_advanced_ud", "x": 270, - "y": -90 + "y": 90 }, "facing=north,orientation=north,state=ud": { "model": "computercraft:block/monitor_advanced_ud" @@ -365,11 +365,11 @@ }, "facing=west,orientation=north,state=ud": { "model": "computercraft:block/monitor_advanced_ud", - "y": 90 + "y": 270 }, "facing=east,orientation=north,state=ud": { "model": "computercraft:block/monitor_advanced_ud", - "y": -90 + "y": 90 }, "facing=north,orientation=down,state=rd": { "model": "computercraft:block/monitor_advanced_rd", @@ -383,12 +383,12 @@ "facing=west,orientation=down,state=rd": { "model": "computercraft:block/monitor_advanced_rd", "x": 90, - "y": 90 + "y": 270 }, "facing=east,orientation=down,state=rd": { "model": "computercraft:block/monitor_advanced_rd", "x": 90, - "y": -90 + "y": 90 }, "facing=north,orientation=up,state=rd": { "model": "computercraft:block/monitor_advanced_rd", @@ -402,12 +402,12 @@ "facing=west,orientation=up,state=rd": { "model": "computercraft:block/monitor_advanced_rd", "x": 270, - "y": 90 + "y": 270 }, "facing=east,orientation=up,state=rd": { "model": "computercraft:block/monitor_advanced_rd", "x": 270, - "y": -90 + "y": 90 }, "facing=north,orientation=north,state=rd": { "model": "computercraft:block/monitor_advanced_rd" @@ -418,11 +418,11 @@ }, "facing=west,orientation=north,state=rd": { "model": "computercraft:block/monitor_advanced_rd", - "y": 90 + "y": 270 }, "facing=east,orientation=north,state=rd": { "model": "computercraft:block/monitor_advanced_rd", - "y": -90 + "y": 90 }, "facing=north,orientation=down,state=ld": { "model": "computercraft:block/monitor_advanced_ld", @@ -436,12 +436,12 @@ "facing=west,orientation=down,state=ld": { "model": "computercraft:block/monitor_advanced_ld", "x": 90, - "y": 90 + "y": 270 }, "facing=east,orientation=down,state=ld": { "model": "computercraft:block/monitor_advanced_ld", "x": 90, - "y": -90 + "y": 90 }, "facing=north,orientation=up,state=ld": { "model": "computercraft:block/monitor_advanced_ld", @@ -455,12 +455,12 @@ "facing=west,orientation=up,state=ld": { "model": "computercraft:block/monitor_advanced_ld", "x": 270, - "y": 90 + "y": 270 }, "facing=east,orientation=up,state=ld": { "model": "computercraft:block/monitor_advanced_ld", "x": 270, - "y": -90 + "y": 90 }, "facing=north,orientation=north,state=ld": { "model": "computercraft:block/monitor_advanced_ld" @@ -471,11 +471,11 @@ }, "facing=west,orientation=north,state=ld": { "model": "computercraft:block/monitor_advanced_ld", - "y": 90 + "y": 270 }, "facing=east,orientation=north,state=ld": { "model": "computercraft:block/monitor_advanced_ld", - "y": -90 + "y": 90 }, "facing=north,orientation=down,state=ru": { "model": "computercraft:block/monitor_advanced_ru", @@ -489,12 +489,12 @@ "facing=west,orientation=down,state=ru": { "model": "computercraft:block/monitor_advanced_ru", "x": 90, - "y": 90 + "y": 270 }, "facing=east,orientation=down,state=ru": { "model": "computercraft:block/monitor_advanced_ru", "x": 90, - "y": -90 + "y": 90 }, "facing=north,orientation=up,state=ru": { "model": "computercraft:block/monitor_advanced_ru", @@ -508,12 +508,12 @@ "facing=west,orientation=up,state=ru": { "model": "computercraft:block/monitor_advanced_ru", "x": 270, - "y": 90 + "y": 270 }, "facing=east,orientation=up,state=ru": { "model": "computercraft:block/monitor_advanced_ru", "x": 270, - "y": -90 + "y": 90 }, "facing=north,orientation=north,state=ru": { "model": "computercraft:block/monitor_advanced_ru" @@ -524,11 +524,11 @@ }, "facing=west,orientation=north,state=ru": { "model": "computercraft:block/monitor_advanced_ru", - "y": 90 + "y": 270 }, "facing=east,orientation=north,state=ru": { "model": "computercraft:block/monitor_advanced_ru", - "y": -90 + "y": 90 }, "facing=north,orientation=down,state=lu": { "model": "computercraft:block/monitor_advanced_lu", @@ -542,12 +542,12 @@ "facing=west,orientation=down,state=lu": { "model": "computercraft:block/monitor_advanced_lu", "x": 90, - "y": 90 + "y": 270 }, "facing=east,orientation=down,state=lu": { "model": "computercraft:block/monitor_advanced_lu", "x": 90, - "y": -90 + "y": 90 }, "facing=north,orientation=up,state=lu": { "model": "computercraft:block/monitor_advanced_lu", @@ -561,12 +561,12 @@ "facing=west,orientation=up,state=lu": { "model": "computercraft:block/monitor_advanced_lu", "x": 270, - "y": 90 + "y": 270 }, "facing=east,orientation=up,state=lu": { "model": "computercraft:block/monitor_advanced_lu", "x": 270, - "y": -90 + "y": 90 }, "facing=north,orientation=north,state=lu": { "model": "computercraft:block/monitor_advanced_lu" @@ -577,11 +577,11 @@ }, "facing=west,orientation=north,state=lu": { "model": "computercraft:block/monitor_advanced_lu", - "y": 90 + "y": 270 }, "facing=east,orientation=north,state=lu": { "model": "computercraft:block/monitor_advanced_lu", - "y": -90 + "y": 90 }, "facing=north,orientation=down,state=lrd": { "model": "computercraft:block/monitor_advanced_lrd", @@ -595,12 +595,12 @@ "facing=west,orientation=down,state=lrd": { "model": "computercraft:block/monitor_advanced_lrd", "x": 90, - "y": 90 + "y": 270 }, "facing=east,orientation=down,state=lrd": { "model": "computercraft:block/monitor_advanced_lrd", "x": 90, - "y": -90 + "y": 90 }, "facing=north,orientation=up,state=lrd": { "model": "computercraft:block/monitor_advanced_lrd", @@ -614,12 +614,12 @@ "facing=west,orientation=up,state=lrd": { "model": "computercraft:block/monitor_advanced_lrd", "x": 270, - "y": 90 + "y": 270 }, "facing=east,orientation=up,state=lrd": { "model": "computercraft:block/monitor_advanced_lrd", "x": 270, - "y": -90 + "y": 90 }, "facing=north,orientation=north,state=lrd": { "model": "computercraft:block/monitor_advanced_lrd" @@ -630,11 +630,11 @@ }, "facing=west,orientation=north,state=lrd": { "model": "computercraft:block/monitor_advanced_lrd", - "y": 90 + "y": 270 }, "facing=east,orientation=north,state=lrd": { "model": "computercraft:block/monitor_advanced_lrd", - "y": -90 + "y": 90 }, "facing=north,orientation=down,state=rud": { "model": "computercraft:block/monitor_advanced_rud", @@ -648,12 +648,12 @@ "facing=west,orientation=down,state=rud": { "model": "computercraft:block/monitor_advanced_rud", "x": 90, - "y": 90 + "y": 270 }, "facing=east,orientation=down,state=rud": { "model": "computercraft:block/monitor_advanced_rud", "x": 90, - "y": -90 + "y": 90 }, "facing=north,orientation=up,state=rud": { "model": "computercraft:block/monitor_advanced_rud", @@ -667,12 +667,12 @@ "facing=west,orientation=up,state=rud": { "model": "computercraft:block/monitor_advanced_rud", "x": 270, - "y": 90 + "y": 270 }, "facing=east,orientation=up,state=rud": { "model": "computercraft:block/monitor_advanced_rud", "x": 270, - "y": -90 + "y": 90 }, "facing=north,orientation=north,state=rud": { "model": "computercraft:block/monitor_advanced_rud" @@ -683,11 +683,11 @@ }, "facing=west,orientation=north,state=rud": { "model": "computercraft:block/monitor_advanced_rud", - "y": 90 + "y": 270 }, "facing=east,orientation=north,state=rud": { "model": "computercraft:block/monitor_advanced_rud", - "y": -90 + "y": 90 }, "facing=north,orientation=down,state=lud": { "model": "computercraft:block/monitor_advanced_lud", @@ -701,12 +701,12 @@ "facing=west,orientation=down,state=lud": { "model": "computercraft:block/monitor_advanced_lud", "x": 90, - "y": 90 + "y": 270 }, "facing=east,orientation=down,state=lud": { "model": "computercraft:block/monitor_advanced_lud", "x": 90, - "y": -90 + "y": 90 }, "facing=north,orientation=up,state=lud": { "model": "computercraft:block/monitor_advanced_lud", @@ -720,12 +720,12 @@ "facing=west,orientation=up,state=lud": { "model": "computercraft:block/monitor_advanced_lud", "x": 270, - "y": 90 + "y": 270 }, "facing=east,orientation=up,state=lud": { "model": "computercraft:block/monitor_advanced_lud", "x": 270, - "y": -90 + "y": 90 }, "facing=north,orientation=north,state=lud": { "model": "computercraft:block/monitor_advanced_lud" @@ -736,11 +736,11 @@ }, "facing=west,orientation=north,state=lud": { "model": "computercraft:block/monitor_advanced_lud", - "y": 90 + "y": 270 }, "facing=east,orientation=north,state=lud": { "model": "computercraft:block/monitor_advanced_lud", - "y": -90 + "y": 90 }, "facing=north,orientation=down,state=lru": { "model": "computercraft:block/monitor_advanced_lru", @@ -754,12 +754,12 @@ "facing=west,orientation=down,state=lru": { "model": "computercraft:block/monitor_advanced_lru", "x": 90, - "y": 90 + "y": 270 }, "facing=east,orientation=down,state=lru": { "model": "computercraft:block/monitor_advanced_lru", "x": 90, - "y": -90 + "y": 90 }, "facing=north,orientation=up,state=lru": { "model": "computercraft:block/monitor_advanced_lru", @@ -773,12 +773,12 @@ "facing=west,orientation=up,state=lru": { "model": "computercraft:block/monitor_advanced_lru", "x": 270, - "y": 90 + "y": 270 }, "facing=east,orientation=up,state=lru": { "model": "computercraft:block/monitor_advanced_lru", "x": 270, - "y": -90 + "y": 90 }, "facing=north,orientation=north,state=lru": { "model": "computercraft:block/monitor_advanced_lru" @@ -789,11 +789,11 @@ }, "facing=west,orientation=north,state=lru": { "model": "computercraft:block/monitor_advanced_lru", - "y": 90 + "y": 270 }, "facing=east,orientation=north,state=lru": { "model": "computercraft:block/monitor_advanced_lru", - "y": -90 + "y": 90 }, "facing=north,orientation=down,state=lrud": { "model": "computercraft:block/monitor_advanced_lrud", @@ -807,12 +807,12 @@ "facing=west,orientation=down,state=lrud": { "model": "computercraft:block/monitor_advanced_lrud", "x": 90, - "y": 90 + "y": 270 }, "facing=east,orientation=down,state=lrud": { "model": "computercraft:block/monitor_advanced_lrud", "x": 90, - "y": -90 + "y": 90 }, "facing=north,orientation=up,state=lrud": { "model": "computercraft:block/monitor_advanced_lrud", @@ -826,12 +826,12 @@ "facing=west,orientation=up,state=lrud": { "model": "computercraft:block/monitor_advanced_lrud", "x": 270, - "y": 90 + "y": 270 }, "facing=east,orientation=up,state=lrud": { "model": "computercraft:block/monitor_advanced_lrud", "x": 270, - "y": -90 + "y": 90 }, "facing=north,orientation=north,state=lrud": { "model": "computercraft:block/monitor_advanced_lrud" @@ -842,11 +842,11 @@ }, "facing=west,orientation=north,state=lrud": { "model": "computercraft:block/monitor_advanced_lrud", - "y": 90 + "y": 270 }, "facing=east,orientation=north,state=lrud": { "model": "computercraft:block/monitor_advanced_lrud", - "y": -90 + "y": 90 } } } \ No newline at end of file diff --git a/src/generated/resources/assets/computercraft/blockstates/monitor_normal.json b/src/generated/resources/assets/computercraft/blockstates/monitor_normal.json index 64d2d4ce9..f3f94002e 100644 --- a/src/generated/resources/assets/computercraft/blockstates/monitor_normal.json +++ b/src/generated/resources/assets/computercraft/blockstates/monitor_normal.json @@ -12,12 +12,12 @@ "facing=west,orientation=down,state=none": { "model": "computercraft:block/monitor_normal", "x": 90, - "y": 90 + "y": 270 }, "facing=east,orientation=down,state=none": { "model": "computercraft:block/monitor_normal", "x": 90, - "y": -90 + "y": 90 }, "facing=north,orientation=up,state=none": { "model": "computercraft:block/monitor_normal", @@ -31,12 +31,12 @@ "facing=west,orientation=up,state=none": { "model": "computercraft:block/monitor_normal", "x": 270, - "y": 90 + "y": 270 }, "facing=east,orientation=up,state=none": { "model": "computercraft:block/monitor_normal", "x": 270, - "y": -90 + "y": 90 }, "facing=north,orientation=north,state=none": { "model": "computercraft:block/monitor_normal" @@ -47,11 +47,11 @@ }, "facing=west,orientation=north,state=none": { "model": "computercraft:block/monitor_normal", - "y": 90 + "y": 270 }, "facing=east,orientation=north,state=none": { "model": "computercraft:block/monitor_normal", - "y": -90 + "y": 90 }, "facing=north,orientation=down,state=l": { "model": "computercraft:block/monitor_normal_l", @@ -65,12 +65,12 @@ "facing=west,orientation=down,state=l": { "model": "computercraft:block/monitor_normal_l", "x": 90, - "y": 90 + "y": 270 }, "facing=east,orientation=down,state=l": { "model": "computercraft:block/monitor_normal_l", "x": 90, - "y": -90 + "y": 90 }, "facing=north,orientation=up,state=l": { "model": "computercraft:block/monitor_normal_l", @@ -84,12 +84,12 @@ "facing=west,orientation=up,state=l": { "model": "computercraft:block/monitor_normal_l", "x": 270, - "y": 90 + "y": 270 }, "facing=east,orientation=up,state=l": { "model": "computercraft:block/monitor_normal_l", "x": 270, - "y": -90 + "y": 90 }, "facing=north,orientation=north,state=l": { "model": "computercraft:block/monitor_normal_l" @@ -100,11 +100,11 @@ }, "facing=west,orientation=north,state=l": { "model": "computercraft:block/monitor_normal_l", - "y": 90 + "y": 270 }, "facing=east,orientation=north,state=l": { "model": "computercraft:block/monitor_normal_l", - "y": -90 + "y": 90 }, "facing=north,orientation=down,state=r": { "model": "computercraft:block/monitor_normal_r", @@ -118,12 +118,12 @@ "facing=west,orientation=down,state=r": { "model": "computercraft:block/monitor_normal_r", "x": 90, - "y": 90 + "y": 270 }, "facing=east,orientation=down,state=r": { "model": "computercraft:block/monitor_normal_r", "x": 90, - "y": -90 + "y": 90 }, "facing=north,orientation=up,state=r": { "model": "computercraft:block/monitor_normal_r", @@ -137,12 +137,12 @@ "facing=west,orientation=up,state=r": { "model": "computercraft:block/monitor_normal_r", "x": 270, - "y": 90 + "y": 270 }, "facing=east,orientation=up,state=r": { "model": "computercraft:block/monitor_normal_r", "x": 270, - "y": -90 + "y": 90 }, "facing=north,orientation=north,state=r": { "model": "computercraft:block/monitor_normal_r" @@ -153,11 +153,11 @@ }, "facing=west,orientation=north,state=r": { "model": "computercraft:block/monitor_normal_r", - "y": 90 + "y": 270 }, "facing=east,orientation=north,state=r": { "model": "computercraft:block/monitor_normal_r", - "y": -90 + "y": 90 }, "facing=north,orientation=down,state=lr": { "model": "computercraft:block/monitor_normal_lr", @@ -171,12 +171,12 @@ "facing=west,orientation=down,state=lr": { "model": "computercraft:block/monitor_normal_lr", "x": 90, - "y": 90 + "y": 270 }, "facing=east,orientation=down,state=lr": { "model": "computercraft:block/monitor_normal_lr", "x": 90, - "y": -90 + "y": 90 }, "facing=north,orientation=up,state=lr": { "model": "computercraft:block/monitor_normal_lr", @@ -190,12 +190,12 @@ "facing=west,orientation=up,state=lr": { "model": "computercraft:block/monitor_normal_lr", "x": 270, - "y": 90 + "y": 270 }, "facing=east,orientation=up,state=lr": { "model": "computercraft:block/monitor_normal_lr", "x": 270, - "y": -90 + "y": 90 }, "facing=north,orientation=north,state=lr": { "model": "computercraft:block/monitor_normal_lr" @@ -206,11 +206,11 @@ }, "facing=west,orientation=north,state=lr": { "model": "computercraft:block/monitor_normal_lr", - "y": 90 + "y": 270 }, "facing=east,orientation=north,state=lr": { "model": "computercraft:block/monitor_normal_lr", - "y": -90 + "y": 90 }, "facing=north,orientation=down,state=u": { "model": "computercraft:block/monitor_normal_u", @@ -224,12 +224,12 @@ "facing=west,orientation=down,state=u": { "model": "computercraft:block/monitor_normal_u", "x": 90, - "y": 90 + "y": 270 }, "facing=east,orientation=down,state=u": { "model": "computercraft:block/monitor_normal_u", "x": 90, - "y": -90 + "y": 90 }, "facing=north,orientation=up,state=u": { "model": "computercraft:block/monitor_normal_u", @@ -243,12 +243,12 @@ "facing=west,orientation=up,state=u": { "model": "computercraft:block/monitor_normal_u", "x": 270, - "y": 90 + "y": 270 }, "facing=east,orientation=up,state=u": { "model": "computercraft:block/monitor_normal_u", "x": 270, - "y": -90 + "y": 90 }, "facing=north,orientation=north,state=u": { "model": "computercraft:block/monitor_normal_u" @@ -259,11 +259,11 @@ }, "facing=west,orientation=north,state=u": { "model": "computercraft:block/monitor_normal_u", - "y": 90 + "y": 270 }, "facing=east,orientation=north,state=u": { "model": "computercraft:block/monitor_normal_u", - "y": -90 + "y": 90 }, "facing=north,orientation=down,state=d": { "model": "computercraft:block/monitor_normal_d", @@ -277,12 +277,12 @@ "facing=west,orientation=down,state=d": { "model": "computercraft:block/monitor_normal_d", "x": 90, - "y": 90 + "y": 270 }, "facing=east,orientation=down,state=d": { "model": "computercraft:block/monitor_normal_d", "x": 90, - "y": -90 + "y": 90 }, "facing=north,orientation=up,state=d": { "model": "computercraft:block/monitor_normal_d", @@ -296,12 +296,12 @@ "facing=west,orientation=up,state=d": { "model": "computercraft:block/monitor_normal_d", "x": 270, - "y": 90 + "y": 270 }, "facing=east,orientation=up,state=d": { "model": "computercraft:block/monitor_normal_d", "x": 270, - "y": -90 + "y": 90 }, "facing=north,orientation=north,state=d": { "model": "computercraft:block/monitor_normal_d" @@ -312,11 +312,11 @@ }, "facing=west,orientation=north,state=d": { "model": "computercraft:block/monitor_normal_d", - "y": 90 + "y": 270 }, "facing=east,orientation=north,state=d": { "model": "computercraft:block/monitor_normal_d", - "y": -90 + "y": 90 }, "facing=north,orientation=down,state=ud": { "model": "computercraft:block/monitor_normal_ud", @@ -330,12 +330,12 @@ "facing=west,orientation=down,state=ud": { "model": "computercraft:block/monitor_normal_ud", "x": 90, - "y": 90 + "y": 270 }, "facing=east,orientation=down,state=ud": { "model": "computercraft:block/monitor_normal_ud", "x": 90, - "y": -90 + "y": 90 }, "facing=north,orientation=up,state=ud": { "model": "computercraft:block/monitor_normal_ud", @@ -349,12 +349,12 @@ "facing=west,orientation=up,state=ud": { "model": "computercraft:block/monitor_normal_ud", "x": 270, - "y": 90 + "y": 270 }, "facing=east,orientation=up,state=ud": { "model": "computercraft:block/monitor_normal_ud", "x": 270, - "y": -90 + "y": 90 }, "facing=north,orientation=north,state=ud": { "model": "computercraft:block/monitor_normal_ud" @@ -365,11 +365,11 @@ }, "facing=west,orientation=north,state=ud": { "model": "computercraft:block/monitor_normal_ud", - "y": 90 + "y": 270 }, "facing=east,orientation=north,state=ud": { "model": "computercraft:block/monitor_normal_ud", - "y": -90 + "y": 90 }, "facing=north,orientation=down,state=rd": { "model": "computercraft:block/monitor_normal_rd", @@ -383,12 +383,12 @@ "facing=west,orientation=down,state=rd": { "model": "computercraft:block/monitor_normal_rd", "x": 90, - "y": 90 + "y": 270 }, "facing=east,orientation=down,state=rd": { "model": "computercraft:block/monitor_normal_rd", "x": 90, - "y": -90 + "y": 90 }, "facing=north,orientation=up,state=rd": { "model": "computercraft:block/monitor_normal_rd", @@ -402,12 +402,12 @@ "facing=west,orientation=up,state=rd": { "model": "computercraft:block/monitor_normal_rd", "x": 270, - "y": 90 + "y": 270 }, "facing=east,orientation=up,state=rd": { "model": "computercraft:block/monitor_normal_rd", "x": 270, - "y": -90 + "y": 90 }, "facing=north,orientation=north,state=rd": { "model": "computercraft:block/monitor_normal_rd" @@ -418,11 +418,11 @@ }, "facing=west,orientation=north,state=rd": { "model": "computercraft:block/monitor_normal_rd", - "y": 90 + "y": 270 }, "facing=east,orientation=north,state=rd": { "model": "computercraft:block/monitor_normal_rd", - "y": -90 + "y": 90 }, "facing=north,orientation=down,state=ld": { "model": "computercraft:block/monitor_normal_ld", @@ -436,12 +436,12 @@ "facing=west,orientation=down,state=ld": { "model": "computercraft:block/monitor_normal_ld", "x": 90, - "y": 90 + "y": 270 }, "facing=east,orientation=down,state=ld": { "model": "computercraft:block/monitor_normal_ld", "x": 90, - "y": -90 + "y": 90 }, "facing=north,orientation=up,state=ld": { "model": "computercraft:block/monitor_normal_ld", @@ -455,12 +455,12 @@ "facing=west,orientation=up,state=ld": { "model": "computercraft:block/monitor_normal_ld", "x": 270, - "y": 90 + "y": 270 }, "facing=east,orientation=up,state=ld": { "model": "computercraft:block/monitor_normal_ld", "x": 270, - "y": -90 + "y": 90 }, "facing=north,orientation=north,state=ld": { "model": "computercraft:block/monitor_normal_ld" @@ -471,11 +471,11 @@ }, "facing=west,orientation=north,state=ld": { "model": "computercraft:block/monitor_normal_ld", - "y": 90 + "y": 270 }, "facing=east,orientation=north,state=ld": { "model": "computercraft:block/monitor_normal_ld", - "y": -90 + "y": 90 }, "facing=north,orientation=down,state=ru": { "model": "computercraft:block/monitor_normal_ru", @@ -489,12 +489,12 @@ "facing=west,orientation=down,state=ru": { "model": "computercraft:block/monitor_normal_ru", "x": 90, - "y": 90 + "y": 270 }, "facing=east,orientation=down,state=ru": { "model": "computercraft:block/monitor_normal_ru", "x": 90, - "y": -90 + "y": 90 }, "facing=north,orientation=up,state=ru": { "model": "computercraft:block/monitor_normal_ru", @@ -508,12 +508,12 @@ "facing=west,orientation=up,state=ru": { "model": "computercraft:block/monitor_normal_ru", "x": 270, - "y": 90 + "y": 270 }, "facing=east,orientation=up,state=ru": { "model": "computercraft:block/monitor_normal_ru", "x": 270, - "y": -90 + "y": 90 }, "facing=north,orientation=north,state=ru": { "model": "computercraft:block/monitor_normal_ru" @@ -524,11 +524,11 @@ }, "facing=west,orientation=north,state=ru": { "model": "computercraft:block/monitor_normal_ru", - "y": 90 + "y": 270 }, "facing=east,orientation=north,state=ru": { "model": "computercraft:block/monitor_normal_ru", - "y": -90 + "y": 90 }, "facing=north,orientation=down,state=lu": { "model": "computercraft:block/monitor_normal_lu", @@ -542,12 +542,12 @@ "facing=west,orientation=down,state=lu": { "model": "computercraft:block/monitor_normal_lu", "x": 90, - "y": 90 + "y": 270 }, "facing=east,orientation=down,state=lu": { "model": "computercraft:block/monitor_normal_lu", "x": 90, - "y": -90 + "y": 90 }, "facing=north,orientation=up,state=lu": { "model": "computercraft:block/monitor_normal_lu", @@ -561,12 +561,12 @@ "facing=west,orientation=up,state=lu": { "model": "computercraft:block/monitor_normal_lu", "x": 270, - "y": 90 + "y": 270 }, "facing=east,orientation=up,state=lu": { "model": "computercraft:block/monitor_normal_lu", "x": 270, - "y": -90 + "y": 90 }, "facing=north,orientation=north,state=lu": { "model": "computercraft:block/monitor_normal_lu" @@ -577,11 +577,11 @@ }, "facing=west,orientation=north,state=lu": { "model": "computercraft:block/monitor_normal_lu", - "y": 90 + "y": 270 }, "facing=east,orientation=north,state=lu": { "model": "computercraft:block/monitor_normal_lu", - "y": -90 + "y": 90 }, "facing=north,orientation=down,state=lrd": { "model": "computercraft:block/monitor_normal_lrd", @@ -595,12 +595,12 @@ "facing=west,orientation=down,state=lrd": { "model": "computercraft:block/monitor_normal_lrd", "x": 90, - "y": 90 + "y": 270 }, "facing=east,orientation=down,state=lrd": { "model": "computercraft:block/monitor_normal_lrd", "x": 90, - "y": -90 + "y": 90 }, "facing=north,orientation=up,state=lrd": { "model": "computercraft:block/monitor_normal_lrd", @@ -614,12 +614,12 @@ "facing=west,orientation=up,state=lrd": { "model": "computercraft:block/monitor_normal_lrd", "x": 270, - "y": 90 + "y": 270 }, "facing=east,orientation=up,state=lrd": { "model": "computercraft:block/monitor_normal_lrd", "x": 270, - "y": -90 + "y": 90 }, "facing=north,orientation=north,state=lrd": { "model": "computercraft:block/monitor_normal_lrd" @@ -630,11 +630,11 @@ }, "facing=west,orientation=north,state=lrd": { "model": "computercraft:block/monitor_normal_lrd", - "y": 90 + "y": 270 }, "facing=east,orientation=north,state=lrd": { "model": "computercraft:block/monitor_normal_lrd", - "y": -90 + "y": 90 }, "facing=north,orientation=down,state=rud": { "model": "computercraft:block/monitor_normal_rud", @@ -648,12 +648,12 @@ "facing=west,orientation=down,state=rud": { "model": "computercraft:block/monitor_normal_rud", "x": 90, - "y": 90 + "y": 270 }, "facing=east,orientation=down,state=rud": { "model": "computercraft:block/monitor_normal_rud", "x": 90, - "y": -90 + "y": 90 }, "facing=north,orientation=up,state=rud": { "model": "computercraft:block/monitor_normal_rud", @@ -667,12 +667,12 @@ "facing=west,orientation=up,state=rud": { "model": "computercraft:block/monitor_normal_rud", "x": 270, - "y": 90 + "y": 270 }, "facing=east,orientation=up,state=rud": { "model": "computercraft:block/monitor_normal_rud", "x": 270, - "y": -90 + "y": 90 }, "facing=north,orientation=north,state=rud": { "model": "computercraft:block/monitor_normal_rud" @@ -683,11 +683,11 @@ }, "facing=west,orientation=north,state=rud": { "model": "computercraft:block/monitor_normal_rud", - "y": 90 + "y": 270 }, "facing=east,orientation=north,state=rud": { "model": "computercraft:block/monitor_normal_rud", - "y": -90 + "y": 90 }, "facing=north,orientation=down,state=lud": { "model": "computercraft:block/monitor_normal_lud", @@ -701,12 +701,12 @@ "facing=west,orientation=down,state=lud": { "model": "computercraft:block/monitor_normal_lud", "x": 90, - "y": 90 + "y": 270 }, "facing=east,orientation=down,state=lud": { "model": "computercraft:block/monitor_normal_lud", "x": 90, - "y": -90 + "y": 90 }, "facing=north,orientation=up,state=lud": { "model": "computercraft:block/monitor_normal_lud", @@ -720,12 +720,12 @@ "facing=west,orientation=up,state=lud": { "model": "computercraft:block/monitor_normal_lud", "x": 270, - "y": 90 + "y": 270 }, "facing=east,orientation=up,state=lud": { "model": "computercraft:block/monitor_normal_lud", "x": 270, - "y": -90 + "y": 90 }, "facing=north,orientation=north,state=lud": { "model": "computercraft:block/monitor_normal_lud" @@ -736,11 +736,11 @@ }, "facing=west,orientation=north,state=lud": { "model": "computercraft:block/monitor_normal_lud", - "y": 90 + "y": 270 }, "facing=east,orientation=north,state=lud": { "model": "computercraft:block/monitor_normal_lud", - "y": -90 + "y": 90 }, "facing=north,orientation=down,state=lru": { "model": "computercraft:block/monitor_normal_lru", @@ -754,12 +754,12 @@ "facing=west,orientation=down,state=lru": { "model": "computercraft:block/monitor_normal_lru", "x": 90, - "y": 90 + "y": 270 }, "facing=east,orientation=down,state=lru": { "model": "computercraft:block/monitor_normal_lru", "x": 90, - "y": -90 + "y": 90 }, "facing=north,orientation=up,state=lru": { "model": "computercraft:block/monitor_normal_lru", @@ -773,12 +773,12 @@ "facing=west,orientation=up,state=lru": { "model": "computercraft:block/monitor_normal_lru", "x": 270, - "y": 90 + "y": 270 }, "facing=east,orientation=up,state=lru": { "model": "computercraft:block/monitor_normal_lru", "x": 270, - "y": -90 + "y": 90 }, "facing=north,orientation=north,state=lru": { "model": "computercraft:block/monitor_normal_lru" @@ -789,11 +789,11 @@ }, "facing=west,orientation=north,state=lru": { "model": "computercraft:block/monitor_normal_lru", - "y": 90 + "y": 270 }, "facing=east,orientation=north,state=lru": { "model": "computercraft:block/monitor_normal_lru", - "y": -90 + "y": 90 }, "facing=north,orientation=down,state=lrud": { "model": "computercraft:block/monitor_normal_lrud", @@ -807,12 +807,12 @@ "facing=west,orientation=down,state=lrud": { "model": "computercraft:block/monitor_normal_lrud", "x": 90, - "y": 90 + "y": 270 }, "facing=east,orientation=down,state=lrud": { "model": "computercraft:block/monitor_normal_lrud", "x": 90, - "y": -90 + "y": 90 }, "facing=north,orientation=up,state=lrud": { "model": "computercraft:block/monitor_normal_lrud", @@ -826,12 +826,12 @@ "facing=west,orientation=up,state=lrud": { "model": "computercraft:block/monitor_normal_lrud", "x": 270, - "y": 90 + "y": 270 }, "facing=east,orientation=up,state=lrud": { "model": "computercraft:block/monitor_normal_lrud", "x": 270, - "y": -90 + "y": 90 }, "facing=north,orientation=north,state=lrud": { "model": "computercraft:block/monitor_normal_lrud" @@ -842,11 +842,11 @@ }, "facing=west,orientation=north,state=lrud": { "model": "computercraft:block/monitor_normal_lrud", - "y": 90 + "y": 270 }, "facing=east,orientation=north,state=lrud": { "model": "computercraft:block/monitor_normal_lrud", - "y": -90 + "y": 90 } } } \ No newline at end of file diff --git a/src/generated/resources/assets/computercraft/models/block/computer_advanced_blinking.json b/src/generated/resources/assets/computercraft/models/block/computer_advanced_blinking.json new file mode 100644 index 000000000..25965f980 --- /dev/null +++ b/src/generated/resources/assets/computercraft/models/block/computer_advanced_blinking.json @@ -0,0 +1,8 @@ +{ + "parent": "block/orientable", + "textures": { + "top": "computercraft:block/computer_advanced_top", + "side": "computercraft:block/computer_advanced_side", + "front": "computercraft:block/computer_advanced_front_blink" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/computercraft/models/block/computer_advanced_off.json b/src/generated/resources/assets/computercraft/models/block/computer_advanced_off.json new file mode 100644 index 000000000..264f6932e --- /dev/null +++ b/src/generated/resources/assets/computercraft/models/block/computer_advanced_off.json @@ -0,0 +1,8 @@ +{ + "parent": "block/orientable", + "textures": { + "top": "computercraft:block/computer_advanced_top", + "side": "computercraft:block/computer_advanced_side", + "front": "computercraft:block/computer_advanced_front" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/computercraft/models/block/computer_advanced_on.json b/src/generated/resources/assets/computercraft/models/block/computer_advanced_on.json new file mode 100644 index 000000000..1a088dadc --- /dev/null +++ b/src/generated/resources/assets/computercraft/models/block/computer_advanced_on.json @@ -0,0 +1,8 @@ +{ + "parent": "block/orientable", + "textures": { + "top": "computercraft:block/computer_advanced_top", + "side": "computercraft:block/computer_advanced_side", + "front": "computercraft:block/computer_advanced_front_on" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/computercraft/models/block/computer_command_blinking.json b/src/generated/resources/assets/computercraft/models/block/computer_command_blinking.json new file mode 100644 index 000000000..4ad39b620 --- /dev/null +++ b/src/generated/resources/assets/computercraft/models/block/computer_command_blinking.json @@ -0,0 +1,8 @@ +{ + "parent": "block/orientable", + "textures": { + "top": "computercraft:block/computer_command_top", + "side": "computercraft:block/computer_command_side", + "front": "computercraft:block/computer_command_front_blink" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/computercraft/models/block/computer_command_off.json b/src/generated/resources/assets/computercraft/models/block/computer_command_off.json new file mode 100644 index 000000000..9223552ef --- /dev/null +++ b/src/generated/resources/assets/computercraft/models/block/computer_command_off.json @@ -0,0 +1,8 @@ +{ + "parent": "block/orientable", + "textures": { + "top": "computercraft:block/computer_command_top", + "side": "computercraft:block/computer_command_side", + "front": "computercraft:block/computer_command_front" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/computercraft/models/block/computer_command_on.json b/src/generated/resources/assets/computercraft/models/block/computer_command_on.json new file mode 100644 index 000000000..635df67ee --- /dev/null +++ b/src/generated/resources/assets/computercraft/models/block/computer_command_on.json @@ -0,0 +1,8 @@ +{ + "parent": "block/orientable", + "textures": { + "top": "computercraft:block/computer_command_top", + "side": "computercraft:block/computer_command_side", + "front": "computercraft:block/computer_command_front_on" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/computercraft/models/block/computer_normal_blinking.json b/src/generated/resources/assets/computercraft/models/block/computer_normal_blinking.json new file mode 100644 index 000000000..fb01777c4 --- /dev/null +++ b/src/generated/resources/assets/computercraft/models/block/computer_normal_blinking.json @@ -0,0 +1,8 @@ +{ + "parent": "block/orientable", + "textures": { + "top": "computercraft:block/computer_normal_top", + "side": "computercraft:block/computer_normal_side", + "front": "computercraft:block/computer_normal_front_blink" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/computercraft/models/block/computer_normal_off.json b/src/generated/resources/assets/computercraft/models/block/computer_normal_off.json new file mode 100644 index 000000000..08288705e --- /dev/null +++ b/src/generated/resources/assets/computercraft/models/block/computer_normal_off.json @@ -0,0 +1,8 @@ +{ + "parent": "block/orientable", + "textures": { + "top": "computercraft:block/computer_normal_top", + "side": "computercraft:block/computer_normal_side", + "front": "computercraft:block/computer_normal_front" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/computercraft/models/block/computer_normal_on.json b/src/generated/resources/assets/computercraft/models/block/computer_normal_on.json new file mode 100644 index 000000000..f5ca31116 --- /dev/null +++ b/src/generated/resources/assets/computercraft/models/block/computer_normal_on.json @@ -0,0 +1,8 @@ +{ + "parent": "block/orientable", + "textures": { + "top": "computercraft:block/computer_normal_top", + "side": "computercraft:block/computer_normal_side", + "front": "computercraft:block/computer_normal_front_on" + } +} \ No newline at end of file diff --git a/src/main/java/dan200/computercraft/data/BlockModelProvider.java b/src/main/java/dan200/computercraft/data/BlockModelProvider.java index 0ab5c92b8..6aea58d25 100644 --- a/src/main/java/dan200/computercraft/data/BlockModelProvider.java +++ b/src/main/java/dan200/computercraft/data/BlockModelProvider.java @@ -8,6 +8,8 @@ package dan200.computercraft.data; import dan200.computercraft.ComputerCraft; import dan200.computercraft.shared.Registry; +import dan200.computercraft.shared.computer.blocks.BlockComputer; +import dan200.computercraft.shared.computer.core.ComputerState; import dan200.computercraft.shared.peripheral.monitor.BlockMonitor; import dan200.computercraft.shared.peripheral.monitor.MonitorEdgeState; import net.minecraft.block.Block; @@ -20,12 +22,14 @@ import javax.annotation.Nonnull; public class BlockModelProvider extends BlockStateProvider { - private final ModelFile root; + private final ModelFile monitorBase; + private final ModelFile orientable; public BlockModelProvider( DataGenerator generator, ExistingFileHelper existingFileHelper ) { super( generator, ComputerCraft.MOD_ID, existingFileHelper ); - root = models().getExistingFile( new ResourceLocation( ComputerCraft.MOD_ID, "block/monitor_base" ) ); + monitorBase = models().getExistingFile( new ResourceLocation( ComputerCraft.MOD_ID, "block/monitor_base" ) ); + orientable = models().getExistingFile( new ResourceLocation( "block/orientable" ) ); } @Nonnull @@ -40,9 +44,35 @@ public class BlockModelProvider extends BlockStateProvider { registerMonitors( Registry.ModBlocks.MONITOR_NORMAL.get() ); registerMonitors( Registry.ModBlocks.MONITOR_ADVANCED.get() ); + + registerComputer( Registry.ModBlocks.COMPUTER_NORMAL.get() ); + registerComputer( Registry.ModBlocks.COMPUTER_ADVANCED.get() ); + registerComputer( Registry.ModBlocks.COMPUTER_COMMAND.get() ); } - private void registerMonitors( Block block ) + private void registerComputer( BlockComputer block ) + { + VariantBlockStateBuilder builder = getVariantBuilder( block ); + for( ComputerState state : BlockComputer.STATE.getAllowedValues() ) + { + BlockModelBuilder model = models() + .getBuilder( suffix( block, "_" + state ) ) + .parent( orientable ) + .texture( "top", suffix( block, "_top" ) ) + .texture( "side", suffix( block, "_side" ) ) + .texture( "front", suffix( block, "_front" + toSuffix( state ) ) ); + + for( Direction facing : BlockComputer.FACING.getAllowedValues() ) + { + builder.partialState() + .with( BlockComputer.STATE, state ) + .with( BlockComputer.FACING, facing ) + .addModels( new ConfiguredModel( model, 0, toYAngle( facing ), false ) ); + } + } + } + + private void registerMonitors( BlockMonitor block ) { String name = block.getRegistryName().getPath(); registerMonitorModel( name, "", 16, 4, 0, 32 ); @@ -66,8 +96,7 @@ public class BlockModelProvider extends BlockStateProvider for( MonitorEdgeState edge : BlockMonitor.STATE.getAllowedValues() ) { String suffix = edge == MonitorEdgeState.NONE ? "" : "_" + edge.getName(); - ResourceLocation modelName = new ResourceLocation( ComputerCraft.MOD_ID, "block/" + name + suffix ); - ModelFile model = models().getBuilder( modelName.toString() ); + ModelFile model = models().getBuilder( suffix( block, suffix ) ); for( Direction facing : BlockMonitor.FACING.getAllowedValues() ) { @@ -77,7 +106,7 @@ public class BlockModelProvider extends BlockStateProvider .with( BlockMonitor.STATE, edge ) .with( BlockMonitor.FACING, facing ) .with( BlockMonitor.ORIENTATION, orientation ) - .addModels( new ConfiguredModel( model, toXAngle( orientation ), 180 - (int) facing.getHorizontalAngle(), false ) ); + .addModels( new ConfiguredModel( model, toXAngle( orientation ), toYAngle( facing ), false ) ); } } } @@ -87,14 +116,14 @@ public class BlockModelProvider extends BlockStateProvider { String texturePrefix = ComputerCraft.MOD_ID + ":block/" + prefix + "_"; models().getBuilder( prefix + corners ) - .parent( root ) + .parent( monitorBase ) .texture( "front", texturePrefix + front ) .texture( "side", texturePrefix + side ) .texture( "top", texturePrefix + top ) .texture( "back", texturePrefix + back ); } - private int toXAngle( Direction direction ) + private static int toXAngle( Direction direction ) { switch( direction ) { @@ -106,4 +135,29 @@ public class BlockModelProvider extends BlockStateProvider return 90; } } + + private static int toYAngle( Direction direction ) + { + return ((int) direction.getHorizontalAngle() + 180) % 360; + } + + private static String toSuffix( ComputerState state ) + { + switch( state ) + { + default: + case OFF: + return ""; + case ON: + return "_on"; + case BLINKING: + return "_blink"; + } + } + + private static String suffix( Block block, String suffix ) + { + ResourceLocation id = block.getRegistryName(); + return new ResourceLocation( id.getNamespace(), "block/" + id.getPath() + suffix ).toString(); + } } diff --git a/src/main/resources/assets/computercraft/blockstates/computer_advanced.json b/src/main/resources/assets/computercraft/blockstates/computer_advanced.json deleted file mode 100644 index f438720d8..000000000 --- a/src/main/resources/assets/computercraft/blockstates/computer_advanced.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "variants": { - "facing=north,state=off": { "model": "computercraft:block/computer_advanced_off" }, - "facing=south,state=off": { "model": "computercraft:block/computer_advanced_off", "y": 180 }, - "facing=west,state=off": { "model": "computercraft:block/computer_advanced_off", "y": 270 }, - "facing=east,state=off": { "model": "computercraft:block/computer_advanced_off", "y": 90 }, - - "facing=north,state=on": { "model": "computercraft:block/computer_advanced_on" }, - "facing=south,state=on": { "model": "computercraft:block/computer_advanced_on", "y": 180 }, - "facing=west,state=on": { "model": "computercraft:block/computer_advanced_on", "y": 270 }, - "facing=east,state=on": { "model": "computercraft:block/computer_advanced_on", "y": 90 }, - - "facing=north,state=blinking": { "model": "computercraft:block/computer_advanced_blinking" }, - "facing=south,state=blinking": { "model": "computercraft:block/computer_advanced_blinking", "y": 180 }, - "facing=west,state=blinking": { "model": "computercraft:block/computer_advanced_blinking", "y": 270 }, - "facing=east,state=blinking": { "model": "computercraft:block/computer_advanced_blinking", "y": 90 } - } -} diff --git a/src/main/resources/assets/computercraft/blockstates/computer_command.json b/src/main/resources/assets/computercraft/blockstates/computer_command.json deleted file mode 100644 index cb45d46c2..000000000 --- a/src/main/resources/assets/computercraft/blockstates/computer_command.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "variants": { - - "facing=north,state=off": { "model": "computercraft:block/computer_command_off" }, - "facing=south,state=off": { "model": "computercraft:block/computer_command_off", "y": 180 }, - "facing=west,state=off": { "model": "computercraft:block/computer_command_off", "y": 270 }, - "facing=east,state=off": { "model": "computercraft:block/computer_command_off", "y": 90 }, - - "facing=north,state=on": { "model": "computercraft:block/computer_command_on" }, - "facing=south,state=on": { "model": "computercraft:block/computer_command_on", "y": 180 }, - "facing=west,state=on": { "model": "computercraft:block/computer_command_on", "y": 270 }, - "facing=east,state=on": { "model": "computercraft:block/computer_command_on", "y": 90 }, - - "facing=north,state=blinking": { "model": "computercraft:block/computer_command_blinking" }, - "facing=south,state=blinking": { "model": "computercraft:block/computer_command_blinking", "y": 180 }, - "facing=west,state=blinking": { "model": "computercraft:block/computer_command_blinking", "y": 270 }, - "facing=east,state=blinking": { "model": "computercraft:block/computer_command_blinking", "y": 90 } - } -} diff --git a/src/main/resources/assets/computercraft/blockstates/computer_normal.json b/src/main/resources/assets/computercraft/blockstates/computer_normal.json deleted file mode 100644 index 95e521a7d..000000000 --- a/src/main/resources/assets/computercraft/blockstates/computer_normal.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "variants": { - "facing=north,state=off": { "model": "computercraft:block/computer_normal_off" }, - "facing=south,state=off": { "model": "computercraft:block/computer_normal_off", "y": 180 }, - "facing=west,state=off": { "model": "computercraft:block/computer_normal_off", "y": 270 }, - "facing=east,state=off": { "model": "computercraft:block/computer_normal_off", "y": 90 }, - - "facing=north,state=on": { "model": "computercraft:block/computer_normal_on" }, - "facing=south,state=on": { "model": "computercraft:block/computer_normal_on", "y": 180 }, - "facing=west,state=on": { "model": "computercraft:block/computer_normal_on", "y": 270 }, - "facing=east,state=on": { "model": "computercraft:block/computer_normal_on", "y": 90 }, - - "facing=north,state=blinking": { "model": "computercraft:block/computer_normal_blinking" }, - "facing=south,state=blinking": { "model": "computercraft:block/computer_normal_blinking", "y": 180 }, - "facing=west,state=blinking": { "model": "computercraft:block/computer_normal_blinking", "y": 270 }, - "facing=east,state=blinking": { "model": "computercraft:block/computer_normal_blinking", "y": 90 } - } -} diff --git a/src/main/resources/assets/computercraft/models/block/computer_advanced_blinking.json b/src/main/resources/assets/computercraft/models/block/computer_advanced_blinking.json deleted file mode 100644 index ed4c9bec3..000000000 --- a/src/main/resources/assets/computercraft/models/block/computer_advanced_blinking.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "parent": "block/orientable", - "textures": { - "front": "computercraft:block/computer_advanced_front_blink", - "side": "computercraft:block/computer_advanced_side", - "top": "computercraft:block/computer_advanced_top" - } -} diff --git a/src/main/resources/assets/computercraft/models/block/computer_advanced_off.json b/src/main/resources/assets/computercraft/models/block/computer_advanced_off.json deleted file mode 100644 index 8631c88ed..000000000 --- a/src/main/resources/assets/computercraft/models/block/computer_advanced_off.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "parent": "block/orientable", - "textures": { - "front": "computercraft:block/computer_advanced_front", - "side": "computercraft:block/computer_advanced_side", - "top": "computercraft:block/computer_advanced_top" - } -} diff --git a/src/main/resources/assets/computercraft/models/block/computer_advanced_on.json b/src/main/resources/assets/computercraft/models/block/computer_advanced_on.json deleted file mode 100644 index 2692aab84..000000000 --- a/src/main/resources/assets/computercraft/models/block/computer_advanced_on.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "parent": "block/orientable", - "textures": { - "front": "computercraft:block/computer_advanced_front_on", - "side": "computercraft:block/computer_advanced_side", - "top": "computercraft:block/computer_advanced_top" - } -} diff --git a/src/main/resources/assets/computercraft/models/block/computer_command_blinking.json b/src/main/resources/assets/computercraft/models/block/computer_command_blinking.json deleted file mode 100644 index 09d7ac1b3..000000000 --- a/src/main/resources/assets/computercraft/models/block/computer_command_blinking.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "parent": "block/orientable", - "textures": { - "front": "computercraft:block/computer_command_front_blink", - "side": "computercraft:block/computer_command_side", - "top": "computercraft:block/computer_command_top" - } -} diff --git a/src/main/resources/assets/computercraft/models/block/computer_command_off.json b/src/main/resources/assets/computercraft/models/block/computer_command_off.json deleted file mode 100644 index eaa4970b9..000000000 --- a/src/main/resources/assets/computercraft/models/block/computer_command_off.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "parent": "block/orientable", - "textures": { - "front": "computercraft:block/computer_command_front", - "side": "computercraft:block/computer_command_side", - "top": "computercraft:block/computer_command_top" - } -} diff --git a/src/main/resources/assets/computercraft/models/block/computer_command_on.json b/src/main/resources/assets/computercraft/models/block/computer_command_on.json deleted file mode 100644 index 7d4730140..000000000 --- a/src/main/resources/assets/computercraft/models/block/computer_command_on.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "parent": "block/orientable", - "textures": { - "front": "computercraft:block/computer_command_front_on", - "side": "computercraft:block/computer_command_side", - "top": "computercraft:block/computer_command_top" - } -} diff --git a/src/main/resources/assets/computercraft/models/block/computer_normal_blinking.json b/src/main/resources/assets/computercraft/models/block/computer_normal_blinking.json deleted file mode 100644 index d6d70f696..000000000 --- a/src/main/resources/assets/computercraft/models/block/computer_normal_blinking.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "parent": "block/orientable", - "textures": { - "front": "computercraft:block/computer_normal_front_blink", - "side": "computercraft:block/computer_normal_side", - "top": "computercraft:block/computer_normal_top" - } -} diff --git a/src/main/resources/assets/computercraft/models/block/computer_normal_off.json b/src/main/resources/assets/computercraft/models/block/computer_normal_off.json deleted file mode 100644 index 5d200f816..000000000 --- a/src/main/resources/assets/computercraft/models/block/computer_normal_off.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "parent": "block/orientable", - "textures": { - "front": "computercraft:block/computer_normal_front", - "side": "computercraft:block/computer_normal_side", - "top": "computercraft:block/computer_normal_top" - } -} diff --git a/src/main/resources/assets/computercraft/models/block/computer_normal_on.json b/src/main/resources/assets/computercraft/models/block/computer_normal_on.json deleted file mode 100644 index f434d7fa8..000000000 --- a/src/main/resources/assets/computercraft/models/block/computer_normal_on.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "parent": "block/orientable", - "textures": { - "front": "computercraft:block/computer_normal_front_on", - "side": "computercraft:block/computer_normal_side", - "top": "computercraft:block/computer_normal_top" - } -} From e2761bb31532685b9acd00ff23b19e744c2b085f Mon Sep 17 00:00:00 2001 From: SquidDev Date: Sat, 28 Nov 2020 12:13:43 +0000 Subject: [PATCH 17/38] Woops I ran the tests, just not checkstyle. --- src/main/java/dan200/computercraft/core/apis/FSAPI.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/dan200/computercraft/core/apis/FSAPI.java b/src/main/java/dan200/computercraft/core/apis/FSAPI.java index 34a2e0f4c..7d189f34a 100644 --- a/src/main/java/dan200/computercraft/core/apis/FSAPI.java +++ b/src/main/java/dan200/computercraft/core/apis/FSAPI.java @@ -91,6 +91,7 @@ public class FSAPI implements ILuaAPI * @return The new path, with separators added between parts as needed. * @cc.tparam string path The first part of the path. For example, a parent directory path. * @cc.tparam string ... Additional parts of the path to combine. + * @throws LuaException On argument errors. */ @LuaFunction public final String combine( IArguments arguments ) throws LuaException From 24af36743d08fcdb58439c52bf587b33ed828263 Mon Sep 17 00:00:00 2001 From: SquidDev Date: Sat, 28 Nov 2020 13:13:35 +0000 Subject: [PATCH 18/38] Try to handle a turtle being broken while ticked Hopefully fixes #585. Hopefully. --- .../pocket/items/ItemPocketComputer.java | 3 ++ .../shared/turtle/core/TurtleBrain.java | 4 +++ .../shared/turtle/upgrades/TurtleTool.java | 31 ++++++++++++------- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/main/java/dan200/computercraft/shared/pocket/items/ItemPocketComputer.java b/src/main/java/dan200/computercraft/shared/pocket/items/ItemPocketComputer.java index a6258216a..f72b28a31 100644 --- a/src/main/java/dan200/computercraft/shared/pocket/items/ItemPocketComputer.java +++ b/src/main/java/dan200/computercraft/shared/pocket/items/ItemPocketComputer.java @@ -257,6 +257,9 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I public static ServerComputer getServerComputer( @Nonnull ItemStack stack ) { + int session = getSessionID( stack ); + if( session != ComputerCraft.serverComputerRegistry.getSessionID() ) return null; + int instanceID = getInstanceID( stack ); return instanceID >= 0 ? ComputerCraft.serverComputerRegistry.get( instanceID ) : null; } diff --git a/src/main/java/dan200/computercraft/shared/turtle/core/TurtleBrain.java b/src/main/java/dan200/computercraft/shared/turtle/core/TurtleBrain.java index 373d0787c..07b3dec26 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/core/TurtleBrain.java +++ b/src/main/java/dan200/computercraft/shared/turtle/core/TurtleBrain.java @@ -128,6 +128,10 @@ public class TurtleBrain implements ITurtleAccess { // Advance movement updateCommands(); + + // The block may have been broken while the command was executing (for instance, if a block explodes + // when being mined). If so, abort. + if( m_owner.isRemoved() ) return; } // Advance animation diff --git a/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleTool.java b/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleTool.java index e3ddec335..f76e7b377 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleTool.java +++ b/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleTool.java @@ -11,6 +11,7 @@ import dan200.computercraft.api.turtle.*; import dan200.computercraft.api.turtle.event.TurtleAttackEvent; import dan200.computercraft.api.turtle.event.TurtleBlockEvent; import dan200.computercraft.shared.TurtlePermissions; +import dan200.computercraft.shared.turtle.core.TurtleBrain; import dan200.computercraft.shared.turtle.core.TurtlePlaceCommand; import dan200.computercraft.shared.turtle.core.TurtlePlayer; import dan200.computercraft.shared.util.DropConsumer; @@ -111,11 +112,14 @@ public class TurtleTool extends AbstractTurtleUpgrade return 3.0f; } - private TurtleCommandResult attack( final ITurtleAccess turtle, Direction direction, TurtleSide side ) + private TurtleCommandResult attack( ITurtleAccess turtle, Direction direction, TurtleSide side ) { // Create a fake player, and orient it appropriately - final World world = turtle.getWorld(); - final BlockPos position = turtle.getPosition(); + World world = turtle.getWorld(); + BlockPos position = turtle.getPosition(); + TileEntity turtleTile = turtle instanceof TurtleBrain ? ((TurtleBrain) turtle).getOwner() : world.getTileEntity( position ); + if( turtleTile == null ) return TurtleCommandResult.failure( "Turtle has vanished from existence." ); + final TurtlePlayer turtlePlayer = TurtlePlaceCommand.createPlayer( turtle, position, direction ); // See if there is an entity present @@ -143,7 +147,7 @@ public class TurtleTool extends AbstractTurtleUpgrade } // Start claiming entity drops - DropConsumer.set( hitEntity, turtleDropConsumer( turtle ) ); + DropConsumer.set( hitEntity, turtleDropConsumer( turtleTile, turtle ) ); // Attack the entity boolean attacked = false; @@ -175,7 +179,7 @@ public class TurtleTool extends AbstractTurtleUpgrade } // Stop claiming drops - stopConsuming( turtle ); + stopConsuming( turtleTile, turtle ); // Put everything we collected into the turtles inventory, then return if( attacked ) @@ -193,8 +197,10 @@ public class TurtleTool extends AbstractTurtleUpgrade // Get ready to dig World world = turtle.getWorld(); BlockPos turtlePosition = turtle.getPosition(); - BlockPos blockPosition = turtlePosition.offset( direction ); + TileEntity turtleTile = turtle instanceof TurtleBrain ? ((TurtleBrain) turtle).getOwner() : world.getTileEntity( turtlePosition ); + if( turtleTile == null ) return TurtleCommandResult.failure( "Turtle has vanished from existence." ); + BlockPos blockPosition = turtlePosition.offset( direction ); if( world.isAirBlock( blockPosition ) || WorldUtil.isLiquidBlock( world, blockPosition ) ) { return TurtleCommandResult.failure( "Nothing to dig here" ); @@ -234,7 +240,7 @@ public class TurtleTool extends AbstractTurtleUpgrade } // Consume the items the block drops - DropConsumer.set( world, blockPosition, turtleDropConsumer( turtle ) ); + DropConsumer.set( world, blockPosition, turtleDropConsumer( turtleTile, turtle ) ); TileEntity tile = world.getTileEntity( blockPosition ); @@ -253,23 +259,24 @@ public class TurtleTool extends AbstractTurtleUpgrade state.getBlock().harvestBlock( world, turtlePlayer, blockPosition, state, tile, turtlePlayer.getHeldItemMainhand() ); } - stopConsuming( turtle ); + stopConsuming( turtleTile, turtle ); return TurtleCommandResult.success(); } - private static Function turtleDropConsumer( ITurtleAccess turtle ) + private static Function turtleDropConsumer( TileEntity tile, ITurtleAccess turtle ) { - return drop -> InventoryUtil.storeItems( drop, turtle.getItemHandler(), turtle.getSelectedSlot() ); + return drop -> tile.isRemoved() ? drop : InventoryUtil.storeItems( drop, turtle.getItemHandler(), turtle.getSelectedSlot() ); } - private static void stopConsuming( ITurtleAccess turtle ) + private static void stopConsuming( TileEntity tile, ITurtleAccess turtle ) { + Direction direction = tile.isRemoved() ? null : turtle.getDirection().getOpposite(); List extra = DropConsumer.clear(); for( ItemStack remainder : extra ) { - WorldUtil.dropItemStack( remainder, turtle.getWorld(), turtle.getPosition(), turtle.getDirection().getOpposite() ); + WorldUtil.dropItemStack( remainder, turtle.getWorld(), turtle.getPosition(), direction ); } } } From 511eea39a11956c82e2c11a47b2e7cad27f9887e Mon Sep 17 00:00:00 2001 From: Jonathan Coates Date: Sat, 28 Nov 2020 17:53:07 +0000 Subject: [PATCH 19/38] Remove s in usages We fixed the bug in illuaminate, so this should be redundant now. --- .../computercraft/lua/rom/modules/main/cc/completion.lua | 8 ++++---- .../data/computercraft/lua/rom/modules/main/cc/pretty.lua | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/resources/data/computercraft/lua/rom/modules/main/cc/completion.lua b/src/main/resources/data/computercraft/lua/rom/modules/main/cc/completion.lua index d07b09506..6315a97cc 100644 --- a/src/main/resources/data/computercraft/lua/rom/modules/main/cc/completion.lua +++ b/src/main/resources/data/computercraft/lua/rom/modules/main/cc/completion.lua @@ -46,7 +46,7 @@ end -- @tparam string text The input string to complete. -- @tparam[opt] boolean add_space Whether to add a space after the completed name. -- @treturn { string... } A list of suffixes of matching peripherals. --- @usage +-- @usage -- local completion = require "cc.completion" -- read(nil, nil, completion.peripheral) local function peripheral_(text, add_space) @@ -62,7 +62,7 @@ local sides = redstone.getSides() -- @tparam string text The input string to complete. -- @tparam[opt] boolean add_space Whether to add a space after the completed side. -- @treturn { string... } A list of suffixes of matching sides. --- @usage +-- @usage -- local completion = require "cc.completion" -- read(nil, nil, completion.side) local function side(text, add_space) @@ -76,7 +76,7 @@ end -- @tparam string text The input string to complete. -- @tparam[opt] boolean add_space Whether to add a space after the completed settings. -- @treturn { string... } A list of suffixes of matching settings. --- @usage +-- @usage -- local completion = require "cc.completion" -- read(nil, nil, completion.setting) local function setting(text, add_space) @@ -92,7 +92,7 @@ local command_list -- @tparam string text The input string to complete. -- @tparam[opt] boolean add_space Whether to add a space after the completed command. -- @treturn { string... } A list of suffixes of matching commands. --- @usage +-- @usage -- local completion = require "cc.completion" -- read(nil, nil, completion.command) local function command(text, add_space) diff --git a/src/main/resources/data/computercraft/lua/rom/modules/main/cc/pretty.lua b/src/main/resources/data/computercraft/lua/rom/modules/main/cc/pretty.lua index 37a70a515..9a3aa7b0a 100644 --- a/src/main/resources/data/computercraft/lua/rom/modules/main/cc/pretty.lua +++ b/src/main/resources/data/computercraft/lua/rom/modules/main/cc/pretty.lua @@ -104,7 +104,7 @@ end -- -- @tparam Doc|string ... The documents to concatenate. -- @treturn Doc The concatenated documents. --- @usage +-- @usage -- local pretty = require "cc.pretty" -- local doc1, doc2 = pretty.text("doc1"), pretty.text("doc2") -- print(pretty.concat(doc1, " - ", doc2)) @@ -141,7 +141,7 @@ Doc.__concat = concat --- @local -- @tparam number depth The number of spaces with which the document should be indented. -- @tparam Doc doc The document to indent. -- @treturn Doc The nested document. --- @usage +-- @usage -- local pretty = require "cc.pretty" -- print(pretty.nest(2, pretty.text("foo\nbar"))) local function nest(depth, doc) From 826797cbd579e867f0f35f0be44b6a28c8c094a9 Mon Sep 17 00:00:00 2001 From: JackMacWindows Date: Sun, 29 Nov 2020 06:24:18 -0500 Subject: [PATCH 20/38] Added documentation for global functions (#592) --- doc/stub/global.lua | 74 ++++++++++++++++++- .../shared/turtle/apis/TurtleAPI.java | 2 +- 2 files changed, 73 insertions(+), 3 deletions(-) diff --git a/doc/stub/global.lua b/doc/stub/global.lua index c0609a1c3..2c0f64ae1 100644 --- a/doc/stub/global.lua +++ b/doc/stub/global.lua @@ -1,6 +1,6 @@ --[[- -Global functions defined by `bios.lua`. This does not include standard Lua -functions. +Functions in the global environment, defined in `bios.lua`. This does not +include standard Lua functions. @module _G ]] @@ -27,18 +27,87 @@ or the @{parallel|parallel API}. nearest multiple of 0.05. @see os.startTimer +@usage Sleep for three seconds. + + print("Sleeping for three seconds") + sleep(3) + print("Done!") ]] function sleep(time) end +--- Writes a line of text to the screen without a newline at the end, wrapping +-- text if necessary. +-- +-- @tparam string text The text to write to the string +-- @treturn number The number of lines written +-- @see print A wrapper around write that adds a newline and accepts multiple arguments +-- @usage write("Hello, world") function write(text) end + +--- Prints the specified values to the screen separated by spaces, wrapping if +-- necessary. After printing, the cursor is moved to the next line. +-- +-- @param ... The values to print on the screen +-- @treturn number The number of lines written +-- @usage print("Hello, world!") function print(...) end + +--- Prints the specified values to the screen in red, separated by spaces, +-- wrapping if necessary. After printing, the cursor is moved to the next line. +-- +-- @param ... The values to print on the screen +-- @usage printError("Something went wrong!") function printError(...) end +--[[- Reads user input from the terminal, automatically handling arrow keys, +pasting, character replacement, history scrollback, auto-completion, and +default values. + +@tparam[opt] string replaceChar A character to replace each typed character with. +This can be used for hiding passwords, for example. +@tparam[opt] table history A table holding history items that can be scrolled +back to with the up/down arrow keys. The oldest item is at index 1, while the +newest item is at the highest index. +@tparam[opt] function(partial: string):({ string... }|nil) completeFn A function +to be used for completion. This function should take the partial text typed so +far, and returns a list of possible completion options. +@tparam[opt] string default Default text which should already be entered into +the prompt. + +@treturn string The text typed in. + +@see cc.completion For functions to help with completion. +@usage Read an string and echo it back to the user + + write("> ") + local msg = read() + print(msg) + +@usage Prompt a user for a password. + + while true do + write("Password> ") + local pwd = read("*") + if pwd == "let me in" then break end + print("Incorrect password, try again.") + end + print("Logged in!") + +@usage A complete example with completion, history and a default value. + + local completion = require "cc.completion" + local history = { "potato", "orange", "apple" } + local choices = { "apple", "orange", "banana", "strawberry" } + write("> ") + local msg = read(nil, history, function(text) return completion.choice(text, choices) end, "app") + print(msg) +]] function read(replaceChar, history, completeFn, default) end --- The ComputerCraft and Minecraft version of the current computer environment. -- -- For example, `ComputerCraft 1.93.0 (Minecraft 1.15.2)`. +-- @usage _HOST _HOST = _HOST --[[- The default computer settings as defined in the ComputerCraft @@ -51,5 +120,6 @@ An example value to disable autocompletion: shell.autocomplete=false,lua.autocomplete=false,edit.autocomplete=false +@usage _CC_DEFAULT_SETTINGS ]] _CC_DEFAULT_SETTINGS = _CC_DEFAULT_SETTINGS diff --git a/src/main/java/dan200/computercraft/shared/turtle/apis/TurtleAPI.java b/src/main/java/dan200/computercraft/shared/turtle/apis/TurtleAPI.java index 57040804c..b96e3f999 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/apis/TurtleAPI.java +++ b/src/main/java/dan200/computercraft/shared/turtle/apis/TurtleAPI.java @@ -501,7 +501,7 @@ public class TurtleAPI implements ILuaAPI } /** - * Get the currently sleected slot. + * Get the currently selected slot. * * @return The current slot. * @see #select From 24d3777722812f975d2bc4594437fbbb0431d910 Mon Sep 17 00:00:00 2001 From: JackMacWindows Date: Wed, 2 Dec 2020 14:22:12 -0500 Subject: [PATCH 21/38] Added improved help viewer (#595) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Pagination, with (page) up/down, q(uit) and scrolling support. - Render markdown style bullets ('-'/'*') using a '•' instead. --- .../computercraft/lua/rom/programs/help.lua | 123 ++++++++++++++++-- .../test-rom/spec/programs/help_spec.lua | 2 +- 2 files changed, 116 insertions(+), 9 deletions(-) diff --git a/src/main/resources/data/computercraft/lua/rom/programs/help.lua b/src/main/resources/data/computercraft/lua/rom/programs/help.lua index 63ece3ab4..149e9f41e 100644 --- a/src/main/resources/data/computercraft/lua/rom/programs/help.lua +++ b/src/main/resources/data/computercraft/lua/rom/programs/help.lua @@ -15,12 +15,119 @@ end local sFile = help.lookup(sTopic) local file = sFile ~= nil and io.open(sFile) or nil -if file then - local sContents = file:read("*a") - file:close() - - local _, nHeight = term.getSize() - textutils.pagedPrint(sContents, nHeight - 3) -else - print("No help available") +if not file then + printError("No help available") + return end + +local contents = file:read("*a"):gsub("(\n *)[-*]( +)", "%1\7%2") +file:close() + +local width, height = term.getSize() +local buffer = window.create(term.current(), 1, 1, width, height, false) +local old_term = term.redirect(buffer) + +local print_height = print(contents) + 1 + +-- If we fit within the screen, just display without pagination. +if print_height <= height then + term.redirect(old_term) + print(contents) + return +end + +local function draw_buffer(width) + buffer.reposition(1, 1, width, print_height) + buffer.clear() + buffer.setCursorPos(1, 1) + print(contents) + term.redirect(old_term) +end + +local offset = 0 + +local function draw() + for y = 1, height - 1 do + term.setCursorPos(1, y) + if y + offset > print_height then + -- Should only happen if we resize the terminal to a larger one + -- than actually needed for the current text. + term.clearLine() + else + term.blit(buffer.getLine(y + offset)) + end + end +end + +local function draw_menu() + term.setTextColor(colors.yellow) + term.setCursorPos(1, height) + term.clearLine() + + local tag = "Help: " .. sTopic + term.write("Help: " .. sTopic) + + if width >= #tag + 16 then + term.setCursorPos(width - 14, height) + term.write("Press Q to exit") + end +end + +draw_buffer(width) +draw() +draw_menu() + +while true do + local event, param = os.pullEvent() + if event == "key" then + if param == keys.up and offset > 0 then + offset = offset - 1 + draw() + elseif param == keys.down and offset < print_height - height then + offset = offset + 1 + draw() + elseif param == keys.pageUp and offset > 0 then + offset = math.max(offset - height + 2, 0) + draw() + elseif param == keys.pageDown and offset < print_height - height then + offset = math.min(offset + height - 2, print_height - height) + draw() + elseif param == keys.home then + offset = 0 + draw() + elseif param == keys["end"] then + offset = print_height - height + draw() + elseif param == keys.q then + sleep(0) -- Super janky, but consumes stray "char" events. + break + end + elseif event == "mouse_scroll" then + if param < 0 and offset > 0 then + offset = offset - 1 + draw() + elseif param > 0 and offset < print_height - height then + offset = offset + 1 + draw() + end + elseif event == "term_resize" then + local new_width, new_height = term.getSize() + + if new_width ~= width then + buffer.setCursorPos(1, 1) + buffer.reposition(1, 1, new_width, print_height) + term.redirect(buffer) + print_height = print(contents) + 1 + draw_buffer(new_width) + end + + width, height = new_width, new_height + offset = math.max(math.min(offset, print_height - height), 0) + draw() + draw_menu() + end +end + +term.redirect(old_term) +term.setCursorPos(1, 1) +term.clear() diff --git a/src/test/resources/test-rom/spec/programs/help_spec.lua b/src/test/resources/test-rom/spec/programs/help_spec.lua index 79e4e4742..35ce021b4 100644 --- a/src/test/resources/test-rom/spec/programs/help_spec.lua +++ b/src/test/resources/test-rom/spec/programs/help_spec.lua @@ -3,6 +3,6 @@ local capture = require "test_helpers".capture_program describe("The help program", function() it("errors when there is no such help file", function() expect(capture(stub, "help nothing")) - :matches { ok = true, output = "No help available\n", error = "" } + :matches { ok = true, error = "No help available\n", output = "" } end) end) From d83a68f3ff6e3833278a38798d06215293656e85 Mon Sep 17 00:00:00 2001 From: SquidDev Date: Sat, 5 Dec 2020 11:32:00 +0000 Subject: [PATCH 22/38] Allow $private HTTP rule to block any private IP This is a little magic compared with our previous approach of "list every private IP range", but given then the sheer number we were missing[1][2] this feels more reasonable. Also refactor out some of the logic into separate classes, hopefully to make things a little cleaner. Fixes #594. [1]: https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml [2]: https://www.iana.org/assignments/iana-ipv6-special-registry/iana-ipv6-special-registry.xhtml --- build.gradle | 5 +- .../dan200/computercraft/ComputerCraft.java | 27 +--- .../apis/http/options/AddressPredicate.java | 149 ++++++++++++++++++ .../core/apis/http/options/AddressRule.java | 144 ++++------------- .../dan200/computercraft/shared/Config.java | 12 +- .../apis/http/options/AddressRuleTest.java | 14 ++ .../test-rom/spec/apis/http_spec.lua | 2 + 7 files changed, 209 insertions(+), 144 deletions(-) create mode 100644 src/main/java/dan200/computercraft/core/apis/http/options/AddressPredicate.java diff --git a/build.gradle b/build.gradle index 4f698a445..e19ddfc25 100644 --- a/build.gradle +++ b/build.gradle @@ -116,8 +116,9 @@ dependencies { shade 'org.squiddev:Cobalt:0.5.1-SNAPSHOT' - testImplementation 'org.junit.jupiter:junit-jupiter-api:5.4.2' - testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.4.2' + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0' + testImplementation 'org.junit.jupiter:junit-jupiter-params:5.7.0' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0' testImplementation 'org.hamcrest:hamcrest:2.2' deployerJars "org.apache.maven.wagon:wagon-ssh:3.0.0" diff --git a/src/main/java/dan200/computercraft/ComputerCraft.java b/src/main/java/dan200/computercraft/ComputerCraft.java index d510ab65b..2daa28eb0 100644 --- a/src/main/java/dan200/computercraft/ComputerCraft.java +++ b/src/main/java/dan200/computercraft/ComputerCraft.java @@ -22,30 +22,17 @@ import net.minecraftforge.fml.common.Mod; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import java.util.Arrays; import java.util.Collections; import java.util.EnumSet; import java.util.List; -import java.util.Objects; import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; -import java.util.stream.Stream; @Mod( ComputerCraft.MOD_ID ) public final class ComputerCraft { public static final String MOD_ID = "computercraft"; - // Configuration options - public static final String[] DEFAULT_HTTP_ALLOW = new String[] { "*" }; - public static final String[] DEFAULT_HTTP_DENY = new String[] { - "127.0.0.0/8", - "0.0.0.0/8", - "10.0.0.0/8", - "172.16.0.0/12", - "192.168.0.0/16", - "fd00::/8", - }; - public static int computerSpaceLimit = 1000 * 1000; public static int floppySpaceLimit = 125 * 1000; public static int maximumFilesOpen = 128; @@ -61,14 +48,10 @@ public final class ComputerCraft public static boolean httpEnabled = true; public static boolean httpWebsocketEnabled = true; - public static List httpRules = Collections.unmodifiableList( Stream.concat( - Stream.of( DEFAULT_HTTP_DENY ) - .map( x -> AddressRule.parse( x, null, Action.DENY.toPartial() ) ) - .filter( Objects::nonNull ), - Stream.of( DEFAULT_HTTP_ALLOW ) - .map( x -> AddressRule.parse( x, null, Action.ALLOW.toPartial() ) ) - .filter( Objects::nonNull ) - ).collect( Collectors.toList() ) ); + public static List httpRules = Collections.unmodifiableList( Arrays.asList( + AddressRule.parse( "$private", null, Action.DENY.toPartial() ), + AddressRule.parse( "*", null, Action.ALLOW.toPartial() ) + ) ); public static int httpMaxRequests = 16; public static int httpMaxWebsockets = 4; diff --git a/src/main/java/dan200/computercraft/core/apis/http/options/AddressPredicate.java b/src/main/java/dan200/computercraft/core/apis/http/options/AddressPredicate.java new file mode 100644 index 000000000..b647f73a3 --- /dev/null +++ b/src/main/java/dan200/computercraft/core/apis/http/options/AddressPredicate.java @@ -0,0 +1,149 @@ +/* + * This file is part of ComputerCraft - http://www.computercraft.info + * Copyright Daniel Ratcliffe, 2011-2020. Do not distribute without permission. + * Send enquiries to dratcliffe@gmail.com + */ + +package dan200.computercraft.core.apis.http.options; + +import com.google.common.net.InetAddresses; +import dan200.computercraft.ComputerCraft; + +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.util.regex.Pattern; + +/** + * A predicate on an address. Matches against a domain and an ip address. + * + * @see AddressRule#apply(Iterable, String, InetSocketAddress) for the actual handling of this rule. + */ +interface AddressPredicate +{ + default boolean matches( String domain ) + { + return false; + } + + default boolean matches( InetAddress socketAddress ) + { + return false; + } + + final class HostRange implements AddressPredicate + { + private final byte[] min; + private final byte[] max; + + HostRange( byte[] min, byte[] max ) + { + this.min = min; + this.max = max; + } + + @Override + public boolean matches( InetAddress address ) + { + byte[] entry = address.getAddress(); + if( entry.length != min.length ) return false; + + for( int i = 0; i < entry.length; i++ ) + { + int value = 0xFF & entry[i]; + if( value < (0xFF & min[i]) || value > (0xFF & max[i]) ) return false; + } + + return true; + } + + public static HostRange parse( String addressStr, String prefixSizeStr ) + { + int prefixSize; + try + { + prefixSize = Integer.parseInt( prefixSizeStr ); + } + catch( NumberFormatException e ) + { + ComputerCraft.log.error( + "Malformed http whitelist/blacklist entry '{}': Cannot extract size of CIDR mask from '{}'.", + addressStr + '/' + prefixSizeStr, prefixSizeStr + ); + return null; + } + + InetAddress address; + try + { + address = InetAddresses.forString( addressStr ); + } + catch( IllegalArgumentException e ) + { + ComputerCraft.log.error( + "Malformed http whitelist/blacklist entry '{}': Cannot extract IP address from '{}'.", + addressStr + '/' + prefixSizeStr, prefixSizeStr + ); + return null; + } + + // Mask the bytes of the IP address. + byte[] minBytes = address.getAddress(), maxBytes = address.getAddress(); + int size = prefixSize; + for( int i = 0; i < minBytes.length; i++ ) + { + if( size <= 0 ) + { + minBytes[i] &= 0; + maxBytes[i] |= 0xFF; + } + else if( size < 8 ) + { + minBytes[i] &= 0xFF << (8 - size); + maxBytes[i] |= ~(0xFF << (8 - size)); + } + + size -= 8; + } + + return new HostRange( minBytes, maxBytes ); + } + } + + final class DomainPattern implements AddressPredicate + { + private final Pattern pattern; + + DomainPattern( Pattern pattern ) + { + this.pattern = pattern; + } + + @Override + public boolean matches( String domain ) + { + return pattern.matcher( domain ).matches(); + } + + @Override + public boolean matches( InetAddress socketAddress ) + { + return pattern.matcher( socketAddress.getHostAddress() ).matches(); + } + } + + + final class PrivatePattern implements AddressPredicate + { + static final PrivatePattern INSTANCE = new PrivatePattern(); + + @Override + public boolean matches( InetAddress socketAddress ) + { + return socketAddress.isAnyLocalAddress() + || socketAddress.isLoopbackAddress() + || socketAddress.isLinkLocalAddress() + || socketAddress.isSiteLocalAddress(); + } + } + +} diff --git a/src/main/java/dan200/computercraft/core/apis/http/options/AddressRule.java b/src/main/java/dan200/computercraft/core/apis/http/options/AddressRule.java index c7498f269..f1884e3f3 100644 --- a/src/main/java/dan200/computercraft/core/apis/http/options/AddressRule.java +++ b/src/main/java/dan200/computercraft/core/apis/http/options/AddressRule.java @@ -6,10 +6,13 @@ package dan200.computercraft.core.apis.http.options; import com.google.common.net.InetAddresses; -import dan200.computercraft.ComputerCraft; +import dan200.computercraft.core.apis.http.options.AddressPredicate.DomainPattern; +import dan200.computercraft.core.apis.http.options.AddressPredicate.HostRange; +import dan200.computercraft.core.apis.http.options.AddressPredicate.PrivatePattern; import javax.annotation.Nonnull; import javax.annotation.Nullable; +import java.net.Inet4Address; import java.net.Inet6Address; import java.net.InetAddress; import java.net.InetSocketAddress; @@ -25,45 +28,13 @@ public final class AddressRule public static final int TIMEOUT = 30_000; public static final int WEBSOCKET_MESSAGE = 128 * 1024; - private static final class HostRange - { - private final byte[] min; - private final byte[] max; - - private HostRange( byte[] min, byte[] max ) - { - this.min = min; - this.max = max; - } - - public boolean contains( InetAddress address ) - { - byte[] entry = address.getAddress(); - if( entry.length != min.length ) return false; - - for( int i = 0; i < entry.length; i++ ) - { - int value = 0xFF & entry[i]; - if( value < (0xFF & min[i]) || value > (0xFF & max[i]) ) return false; - } - - return true; - } - } - - private final HostRange ip; - private final Pattern domainPattern; + private final AddressPredicate predicate; private final Integer port; private final PartialOptions partial; - private AddressRule( - @Nullable HostRange ip, - @Nullable Pattern domainPattern, - @Nullable Integer port, - @Nonnull PartialOptions partial ) + private AddressRule( @Nonnull AddressPredicate predicate, @Nullable Integer port, @Nonnull PartialOptions partial ) { - this.ip = ip; - this.domainPattern = domainPattern; + this.predicate = predicate; this.partial = partial; this.port = port; } @@ -76,103 +47,50 @@ public final class AddressRule { String addressStr = filter.substring( 0, cidr ); String prefixSizeStr = filter.substring( cidr + 1 ); - - int prefixSize; - try - { - prefixSize = Integer.parseInt( prefixSizeStr ); - } - catch( NumberFormatException e ) - { - ComputerCraft.log.error( - "Malformed http whitelist/blacklist entry '{}': Cannot extract size of CIDR mask from '{}'.", - filter, prefixSizeStr - ); - return null; - } - - InetAddress address; - try - { - address = InetAddresses.forString( addressStr ); - } - catch( IllegalArgumentException e ) - { - ComputerCraft.log.error( - "Malformed http whitelist/blacklist entry '{}': Cannot extract IP address from '{}'.", - filter, prefixSizeStr - ); - return null; - } - - // Mask the bytes of the IP address. - byte[] minBytes = address.getAddress(), maxBytes = address.getAddress(); - int size = prefixSize; - for( int i = 0; i < minBytes.length; i++ ) - { - if( size <= 0 ) - { - minBytes[i] &= 0; - maxBytes[i] |= 0xFF; - } - else if( size < 8 ) - { - minBytes[i] &= 0xFF << (8 - size); - maxBytes[i] |= ~(0xFF << (8 - size)); - } - - size -= 8; - } - - return new AddressRule( new HostRange( minBytes, maxBytes ), null, port, partial ); + HostRange range = HostRange.parse( addressStr, prefixSizeStr ); + return range == null ? null : new AddressRule( range, port, partial ); + } + else if( filter.equalsIgnoreCase( "$private" ) ) + { + return new AddressRule( PrivatePattern.INSTANCE, port, partial ); } else { - Pattern pattern = Pattern.compile( "^\\Q" + filter.replaceAll( "\\*", "\\\\E.*\\\\Q" ) + "\\E$" ); - return new AddressRule( null, pattern, port, partial ); + Pattern pattern = Pattern.compile( "^\\Q" + filter.replaceAll( "\\*", "\\\\E.*\\\\Q" ) + "\\E$", Pattern.CASE_INSENSITIVE ); + return new AddressRule( new DomainPattern( pattern ), port, partial ); } } /** * Determine whether the given address matches a series of patterns. * - * @param domain The domain to match - * @param socketAddress The address to check. + * @param domain The domain to match + * @param port The port of the address. + * @param address The address to check. + * @param ipv4Address An ipv4 version of the address, if the original was an ipv6 address. * @return Whether it matches any of these patterns. */ - private boolean matches( String domain, InetSocketAddress socketAddress ) + private boolean matches( String domain, int port, InetAddress address, Inet4Address ipv4Address ) { - InetAddress address = socketAddress.getAddress(); - if( port != null && port != socketAddress.getPort() ) return false; - - if( domainPattern != null ) - { - if( domainPattern.matcher( domain ).matches() ) return true; - if( domainPattern.matcher( address.getHostName() ).matches() ) return true; - } - - // Match the normal address - if( matchesAddress( address ) ) return true; - - // If we're an IPv4 address in disguise then let's check that. - return address instanceof Inet6Address && InetAddresses.is6to4Address( (Inet6Address) address ) - && matchesAddress( InetAddresses.get6to4IPv4Address( (Inet6Address) address ) ); + if( this.port != null && this.port != port ) return false; + return predicate.matches( domain ) + || predicate.matches( address ) + || (ipv4Address != null && predicate.matches( ipv4Address )); } - private boolean matchesAddress( InetAddress address ) - { - if( domainPattern != null && domainPattern.matcher( address.getHostAddress() ).matches() ) return true; - return ip != null && ip.contains( address ); - } - - public static Options apply( Iterable rules, String domain, InetSocketAddress address ) + public static Options apply( Iterable rules, String domain, InetSocketAddress socketAddress ) { PartialOptions options = null; boolean hasMany = false; + int port = socketAddress.getPort(); + InetAddress address = socketAddress.getAddress(); + Inet4Address ipv4Address = address instanceof Inet6Address && InetAddresses.is6to4Address( (Inet6Address) address ) + ? InetAddresses.get6to4IPv4Address( (Inet6Address) address ) : null; + for( AddressRule rule : rules ) { - if( !rule.matches( domain, address ) ) continue; + if( !rule.matches( domain, port, address, ipv4Address ) ) continue; if( options == null ) { diff --git a/src/main/java/dan200/computercraft/shared/Config.java b/src/main/java/dan200/computercraft/shared/Config.java index a39f513f6..6655d6fd5 100644 --- a/src/main/java/dan200/computercraft/shared/Config.java +++ b/src/main/java/dan200/computercraft/shared/Config.java @@ -21,12 +21,12 @@ import net.minecraftforge.fml.ModLoadingContext; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.config.ModConfig; +import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Objects; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; -import java.util.stream.Stream; import static net.minecraftforge.common.ForgeConfigSpec.Builder; import static net.minecraftforge.common.ForgeConfigSpec.ConfigValue; @@ -180,12 +180,10 @@ public final class Config "Each rule is an item with a 'host' to match against, and a series of properties. " + "The host may be a domain name (\"pastebin.com\"),\n" + "wildcard (\"*.pastebin.com\") or CIDR notation (\"127.0.0.0/8\"). If no rules, the domain is blocked." ) - .defineList( "rules", - Stream.concat( - Stream.of( ComputerCraft.DEFAULT_HTTP_DENY ).map( x -> AddressRuleConfig.makeRule( x, Action.DENY ) ), - Stream.of( ComputerCraft.DEFAULT_HTTP_ALLOW ).map( x -> AddressRuleConfig.makeRule( x, Action.ALLOW ) ) - ).collect( Collectors.toList() ), - x -> x instanceof UnmodifiableConfig && AddressRuleConfig.checkRule( (UnmodifiableConfig) x ) ); + .defineList( "rules", Arrays.asList( + AddressRuleConfig.makeRule( "$private", Action.DENY ), + AddressRuleConfig.makeRule( "*", Action.ALLOW ) + ), x -> x instanceof UnmodifiableConfig && AddressRuleConfig.checkRule( (UnmodifiableConfig) x ) ); httpMaxRequests = builder .comment( "The number of http requests a computer can make at one time. Additional requests will be queued, and sent when the running requests have finished. Set to 0 for unlimited." ) diff --git a/src/test/java/dan200/computercraft/core/apis/http/options/AddressRuleTest.java b/src/test/java/dan200/computercraft/core/apis/http/options/AddressRuleTest.java index 690cb37f5..3a8246e7f 100644 --- a/src/test/java/dan200/computercraft/core/apis/http/options/AddressRuleTest.java +++ b/src/test/java/dan200/computercraft/core/apis/http/options/AddressRuleTest.java @@ -6,7 +6,10 @@ package dan200.computercraft.core.apis.http.options; +import dan200.computercraft.ComputerCraft; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import java.net.InetSocketAddress; import java.util.Collections; @@ -27,6 +30,17 @@ public class AddressRuleTest assertEquals( apply( rules, "localhost", 8081 ).action, Action.DENY ); } + @ParameterizedTest + @ValueSource( strings = { + "0.0.0.0", "[::]", + "localhost", "lvh.me", "127.0.0.1", "[::1]", + "172.17.0.1", "192.168.1.114", "[0:0:0:0:0:ffff:c0a8:172]", "10.0.0.1" + } ) + public void blocksLocalDomains( String domain ) + { + assertEquals( apply( ComputerCraft.httpRules, domain, 80 ).action, Action.DENY ); + } + private Options apply( Iterable rules, String host, int port ) { return AddressRule.apply( rules, host, new InetSocketAddress( host, port ) ); diff --git a/src/test/resources/test-rom/spec/apis/http_spec.lua b/src/test/resources/test-rom/spec/apis/http_spec.lua index ecaf1d307..4a6a8b803 100644 --- a/src/test/resources/test-rom/spec/apis/http_spec.lua +++ b/src/test/resources/test-rom/spec/apis/http_spec.lua @@ -12,6 +12,8 @@ describe("The http library", function() end) it("rejects local domains", function() + -- Note, this is tested more thoroughly in AddressRuleTest. We've just got this here + -- to ensure the general control flow works. expect({ http.checkURL("http://localhost") }):same({ false, "Domain not permitted" }) expect({ http.checkURL("http://127.0.0.1") }):same({ false, "Domain not permitted" }) end) From 737b3cb57696fb5517252e7db38bc88ce960b4d8 Mon Sep 17 00:00:00 2001 From: SquidDev Date: Thu, 10 Dec 2020 19:02:08 +0000 Subject: [PATCH 23/38] Don't use capabilities for generic peripherals Maybe the capability system was a mistake in retrospect, as we don't store the peripheral outside, so there's no way to reuse it. That will probably come in a later change. As a smaller fix, we pass the invalidate listener directly. The lifetime of this is the same as the computer, so we don't create a new one each time. There's still the potential to leak memory if people break/replace a computer (as listeners aren't removed), but that's an unavoidable flaw with capabilities. Fixes #593 --- .../computercraft/shared/Peripherals.java | 2 +- .../computer/blocks/TileComputerBase.java | 13 ++++++++++++- .../generic/GenericPeripheralProvider.java | 19 +++++++++++++------ 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/main/java/dan200/computercraft/shared/Peripherals.java b/src/main/java/dan200/computercraft/shared/Peripherals.java index cc61e4451..1d93147b4 100644 --- a/src/main/java/dan200/computercraft/shared/Peripherals.java +++ b/src/main/java/dan200/computercraft/shared/Peripherals.java @@ -67,7 +67,7 @@ public final class Peripherals } } - return CapabilityUtil.unwrap( GenericPeripheralProvider.getPeripheral( world, pos, side ), invalidate ); + return GenericPeripheralProvider.getPeripheral( world, pos, side, invalidate ); } } diff --git a/src/main/java/dan200/computercraft/shared/computer/blocks/TileComputerBase.java b/src/main/java/dan200/computercraft/shared/computer/blocks/TileComputerBase.java index b384810b9..e904e02f4 100644 --- a/src/main/java/dan200/computercraft/shared/computer/blocks/TileComputerBase.java +++ b/src/main/java/dan200/computercraft/shared/computer/blocks/TileComputerBase.java @@ -39,6 +39,8 @@ import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.StringTextComponent; import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.World; +import net.minecraftforge.common.util.LazyOptional; +import net.minecraftforge.common.util.NonNullConsumer; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -56,6 +58,7 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT private boolean m_on = false; boolean m_startOn = false; private boolean m_fresh = false; + private final NonNullConsumer>[] invalidate; private final ComputerFamily family; @@ -63,6 +66,14 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT { super( type ); this.family = family; + + // We cache these so we can guarantee we only ever register one listener for adjacent capabilities. + @SuppressWarnings( { "unchecked", "rawtypes" } ) + NonNullConsumer>[] invalidate = this.invalidate = new NonNullConsumer[6]; + for( Direction direction : Direction.values() ) + { + invalidate[direction.ordinal()] = o -> updateInput( direction ); + } } protected void unload() @@ -225,7 +236,7 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT computer.setBundledRedstoneInput( localDir, BundledRedstone.getOutput( getWorld(), offset, offsetSide ) ); if( !isPeripheralBlockedOnSide( localDir ) ) { - IPeripheral peripheral = Peripherals.getPeripheral( getWorld(), offset, offsetSide, o -> updateInput( dir ) ); + IPeripheral peripheral = Peripherals.getPeripheral( getWorld(), offset, offsetSide, invalidate[dir.ordinal()] ); computer.setPeripheral( localDir, peripheral ); } } diff --git a/src/main/java/dan200/computercraft/shared/peripheral/generic/GenericPeripheralProvider.java b/src/main/java/dan200/computercraft/shared/peripheral/generic/GenericPeripheralProvider.java index 149179b84..260f8d781 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/generic/GenericPeripheralProvider.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/generic/GenericPeripheralProvider.java @@ -15,11 +15,13 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.LazyOptional; +import net.minecraftforge.common.util.NonNullConsumer; import net.minecraftforge.energy.CapabilityEnergy; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.items.CapabilityItemHandler; import javax.annotation.Nonnull; +import javax.annotation.Nullable; import java.util.ArrayList; import java.util.List; @@ -31,14 +33,13 @@ public class GenericPeripheralProvider CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, }; - @Nonnull - public static LazyOptional getPeripheral( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull Direction side ) + @Nullable + public static IPeripheral getPeripheral( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull Direction side, NonNullConsumer> invalidate ) { TileEntity tile = world.getTileEntity( pos ); - if( tile == null ) return LazyOptional.empty(); + if( tile == null ) return null; ArrayList saturated = new ArrayList<>( 0 ); - LazyOptional peripheral = LazyOptional.of( () -> new GenericPeripheral( tile, saturated ) ); List> tileMethods = PeripheralMethod.GENERATOR.getMethods( tile.getClass() ); if( !tileMethods.isEmpty() ) addSaturated( saturated, tile, tileMethods ); @@ -51,11 +52,11 @@ public class GenericPeripheralProvider if( capabilityMethods.isEmpty() ) return; addSaturated( saturated, contents, capabilityMethods ); - wrapper.addListener( x -> peripheral.invalidate() ); + wrapper.addListener( cast( invalidate ) ); } ); } - return saturated.isEmpty() ? LazyOptional.empty() : peripheral; + return saturated.isEmpty() ? null : new GenericPeripheral( tile, saturated ); } private static void addSaturated( ArrayList saturated, Object target, List> methods ) @@ -66,4 +67,10 @@ public class GenericPeripheralProvider saturated.add( new SaturatedMethod( target, method ) ); } } + + @SuppressWarnings( { "unchecked", "rawtypes" } ) + private static NonNullConsumer cast( NonNullConsumer consumer ) + { + return (NonNullConsumer) consumer; + } } From ea3a16036794357c3a44edffc90fdb652e03881e Mon Sep 17 00:00:00 2001 From: SquidDev Date: Thu, 10 Dec 2020 19:05:31 +0000 Subject: [PATCH 24/38] Remove a couple of todos --- .../computercraft/client/proxy/ComputerCraftProxyClient.java | 1 - .../computercraft/client/render/MonitorTextureBufferShader.java | 1 - 2 files changed, 2 deletions(-) diff --git a/src/main/java/dan200/computercraft/client/proxy/ComputerCraftProxyClient.java b/src/main/java/dan200/computercraft/client/proxy/ComputerCraftProxyClient.java index 70147c4c6..c8c8374c9 100644 --- a/src/main/java/dan200/computercraft/client/proxy/ComputerCraftProxyClient.java +++ b/src/main/java/dan200/computercraft/client/proxy/ComputerCraftProxyClient.java @@ -47,7 +47,6 @@ public final class ComputerCraftProxyClient ClientRegistry.bindTileEntityRenderer( Registry.ModTiles.MONITOR_ADVANCED.get(), TileEntityMonitorRenderer::new ); ClientRegistry.bindTileEntityRenderer( Registry.ModTiles.TURTLE_NORMAL.get(), TileEntityTurtleRenderer::new ); ClientRegistry.bindTileEntityRenderer( Registry.ModTiles.TURTLE_ADVANCED.get(), TileEntityTurtleRenderer::new ); - // TODO: ClientRegistry.bindTileEntityRenderer( TileCable.FACTORY, x -> new TileEntityCableRenderer() ); RenderingRegistry.registerEntityRenderingHandler( Registry.ModEntities.TURTLE_PLAYER.get(), TurtlePlayerRenderer::new ); } diff --git a/src/main/java/dan200/computercraft/client/render/MonitorTextureBufferShader.java b/src/main/java/dan200/computercraft/client/render/MonitorTextureBufferShader.java index 483957a31..570761186 100644 --- a/src/main/java/dan200/computercraft/client/render/MonitorTextureBufferShader.java +++ b/src/main/java/dan200/computercraft/client/render/MonitorTextureBufferShader.java @@ -50,7 +50,6 @@ class MonitorTextureBufferShader RenderSystem.glUniform1i( uniformWidth, width ); RenderSystem.glUniform1i( uniformHeight, height ); - // TODO: Cache this? Maybe?? PALETTE_BUFFER.rewind(); for( int i = 0; i < 16; i++ ) { From bb8f4c624bf87169b73fb631d8250cfc38181e15 Mon Sep 17 00:00:00 2001 From: SquidDev Date: Thu, 10 Dec 2020 19:13:49 +0000 Subject: [PATCH 25/38] Some sanity checks for get{Direction,Orientation} Silly bodge, but should fix #600. --- .../shared/peripheral/monitor/TileMonitor.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/dan200/computercraft/shared/peripheral/monitor/TileMonitor.java b/src/main/java/dan200/computercraft/shared/peripheral/monitor/TileMonitor.java index e9ba5e304..7e9193d91 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/monitor/TileMonitor.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/monitor/TileMonitor.java @@ -14,6 +14,7 @@ import dan200.computercraft.shared.common.TileGeneric; import dan200.computercraft.shared.network.client.TerminalState; import dan200.computercraft.shared.util.CapabilityUtil; import dan200.computercraft.shared.util.TickScheduler; +import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.TileEntity; @@ -325,12 +326,16 @@ public class TileMonitor extends TileGeneric // region Sizing and placement stuff public Direction getDirection() { - return getBlockState().get( BlockMonitor.FACING ); + // Ensure we're actually a monitor block. This _should_ always be the case, but sometimes there's + // fun problems with the block being missing on the client. + BlockState state = getBlockState(); + return state.has( BlockMonitor.FACING ) ? state.get( BlockMonitor.FACING ) : Direction.NORTH; } public Direction getOrientation() { - return getBlockState().get( BlockMonitor.ORIENTATION ); + BlockState state = getBlockState(); + return state.has( BlockMonitor.ORIENTATION ) ? state.get( BlockMonitor.ORIENTATION ) : Direction.NORTH; } public Direction getFront() From 05c3c8ad3269c9025757f9261e7f609889fb6bdc Mon Sep 17 00:00:00 2001 From: SquidDev Date: Thu, 10 Dec 2020 22:16:49 +0000 Subject: [PATCH 26/38] Generate docs for generic peripherals This was the easy bit. Now I've got to write them! --- build.gradle | 3 ++- illuaminate.sexp | 7 ++++++- .../shared/peripheral/generic/methods/EnergyMethods.java | 5 +++++ .../shared/peripheral/generic/methods/FluidMethods.java | 5 +++++ .../peripheral/generic/methods/InventoryMethods.java | 5 +++++ 5 files changed, 23 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index e19ddfc25..3ca948a14 100644 --- a/build.gradle +++ b/build.gradle @@ -123,7 +123,7 @@ dependencies { deployerJars "org.apache.maven.wagon:wagon-ssh:3.0.0" - cctJavadoc 'cc.tweaked:cct-javadoc:1.2.1' + cctJavadoc 'cc.tweaked:cct-javadoc:1.3.0' } // Compile tasks @@ -346,6 +346,7 @@ task illuaminateDocs(type: Exec, dependsOn: [minifyWeb, luaJavadoc]) { inputs.files(fileTree("doc")).withPropertyName("docs") inputs.files(fileTree("src/main/resources/data/computercraft/lua/rom")).withPropertyName("lua rom") inputs.file("illuaminate.sexp").withPropertyName("illuaminate.sexp") + inputs.dir("$buildDir/docs/luaJavadoc") inputs.file("$buildDir/rollup/index.min.js").withPropertyName("scripts") inputs.file("src/web/styles.css").withPropertyName("styles") outputs.dir("$buildDir/docs/lua") diff --git a/illuaminate.sexp b/illuaminate.sexp index 6bf2d2688..d020482f9 100644 --- a/illuaminate.sexp +++ b/illuaminate.sexp @@ -19,7 +19,8 @@ (source-link https://github.com/SquidDev-CC/CC-Tweaked/blob/${commit}/${path}#L${line}) (module-kinds - (peripheral Peripherals)) + (peripheral Peripherals) + (generic_peripheral "Generic Peripherals")) (library-path /doc/stub/ @@ -91,6 +92,10 @@ /build/docs/luaJavadoc/drive.lua /build/docs/luaJavadoc/speaker.lua /build/docs/luaJavadoc/printer.lua + ; Generic peripherals + /build/docs/luaJavadoc/energy_storage.lua + /build/docs/luaJavadoc/fluid_storage.lua + /build/docs/luaJavadoc/inventory.lua ; Lua APIs /src/main/resources/*/computercraft/lua/rom/apis/io.lua /src/main/resources/*/computercraft/lua/rom/apis/window.lua) diff --git a/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/EnergyMethods.java b/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/EnergyMethods.java index 1123318d3..6d0d705ff 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/EnergyMethods.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/EnergyMethods.java @@ -15,6 +15,11 @@ import net.minecraftforge.versions.forge.ForgeVersion; import javax.annotation.Nonnull; +/** + * Methods for interacting with blocks using Forge's energy storage system. + * + * @cc.module energy_storage + */ @AutoService( GenericSource.class ) public class EnergyMethods implements GenericSource { diff --git a/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/FluidMethods.java b/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/FluidMethods.java index 26b631f68..1dfe5a2a0 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/FluidMethods.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/FluidMethods.java @@ -31,6 +31,11 @@ import java.util.Optional; import static dan200.computercraft.shared.peripheral.generic.methods.ArgumentHelpers.getRegistryEntry; +/** + * Methods for interacting with tanks and other fluid storage blocks. + * + * @cc.module fluid_storage + */ @AutoService( GenericSource.class ) public class FluidMethods implements GenericSource { diff --git a/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/InventoryMethods.java b/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/InventoryMethods.java index 405532b0b..e2e5269c9 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/InventoryMethods.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/InventoryMethods.java @@ -32,6 +32,11 @@ import java.util.Optional; import static dan200.computercraft.shared.peripheral.generic.methods.ArgumentHelpers.assertBetween; +/** + * Methods for interacting with inventories. + * + * @cc.module inventory + */ @AutoService( GenericSource.class ) public class InventoryMethods implements GenericSource { From 85cf2d5ff1b63010de4661301801aa504e5b9015 Mon Sep 17 00:00:00 2001 From: SquidDev Date: Fri, 11 Dec 2020 21:26:36 +0000 Subject: [PATCH 27/38] Docs for energy and inventory methods The inventory transfer methods really need a proper tutorial with screenshots and everything else, but this is a good starting point, I guess. --- illuaminate.sexp | 2 - .../generic/methods/EnergyMethods.java | 17 ++++ .../generic/methods/InventoryMethods.java | 79 ++++++++++++++++++- 3 files changed, 94 insertions(+), 4 deletions(-) diff --git a/illuaminate.sexp b/illuaminate.sexp index d020482f9..3922ec02b 100644 --- a/illuaminate.sexp +++ b/illuaminate.sexp @@ -93,9 +93,7 @@ /build/docs/luaJavadoc/speaker.lua /build/docs/luaJavadoc/printer.lua ; Generic peripherals - /build/docs/luaJavadoc/energy_storage.lua /build/docs/luaJavadoc/fluid_storage.lua - /build/docs/luaJavadoc/inventory.lua ; Lua APIs /src/main/resources/*/computercraft/lua/rom/apis/io.lua /src/main/resources/*/computercraft/lua/rom/apis/window.lua) diff --git a/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/EnergyMethods.java b/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/EnergyMethods.java index 6d0d705ff..5df9a7993 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/EnergyMethods.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/EnergyMethods.java @@ -18,6 +18,13 @@ import javax.annotation.Nonnull; /** * Methods for interacting with blocks using Forge's energy storage system. * + * This works with energy storage blocks, as well as generators and machines which consume energy. + * + *
+ * Note: Due to limitations with Forge's energy API, it is not possible to measure throughput (i.e. RF + * used/generated per tick). + *
+ * * @cc.module energy_storage */ @AutoService( GenericSource.class ) @@ -30,12 +37,22 @@ public class EnergyMethods implements GenericSource return new ResourceLocation( ForgeVersion.MOD_ID, "energy" ); } + /** + * Get the energy of this block. + * + * @return The energy stored in this block, in FE. + */ @LuaFunction( mainThread = true ) public static int getEnergy( IEnergyStorage energy ) { return energy.getEnergyStored(); } + /** + * Get the maximum amount of energy this block can store. + * + * @return The energy capacity of this block. + */ @LuaFunction( mainThread = true ) public static int getEnergyCapacity( IEnergyStorage energy ) { diff --git a/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/InventoryMethods.java b/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/InventoryMethods.java index e2e5269c9..4c4864386 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/InventoryMethods.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/InventoryMethods.java @@ -47,12 +47,30 @@ public class InventoryMethods implements GenericSource return new ResourceLocation( ForgeVersion.MOD_ID, "inventory" ); } + /** + * Get the size of this inventory. + * + * @return The number of slots in this inventory. + */ @LuaFunction( mainThread = true ) public static int size( IItemHandler inventory ) { return inventory.getSlots(); } + /** + * List all items in this inventory. This returns a table, with an entry for each slot. + * + * Each item in the inventory is represented by a table containing some basic information, much like + * {@link dan200.computercraft.shared.turtle.apis.TurtleAPI#getItemDetail} includes. More information can be fetched + * with {@link #getItemDetail}. + * + * The table is sparse, and so empty slots will be `nil` - it is recommended to loop over using `pairs` rather than + * `ipairs`. + * + * @return All items in this inventory. + * @cc.treturn { (table|nil)... } All items in this inventory. + */ @LuaFunction( mainThread = true ) public static Map> list( IItemHandler inventory ) { @@ -67,6 +85,15 @@ public class InventoryMethods implements GenericSource return result; } + /** + * Get detailed information about an item. + * + * @param slot The slot to get information about. + * @return Information about the item in this slot, or {@code nil} if not present. + * @throws LuaException If the slot is out of range. + * @cc.treturn table Information about the item in this slot, or {@code nil} if not present. + */ + @Nullable @LuaFunction( mainThread = true ) public static Map getItemDetail( IItemHandler inventory, int slot ) throws LuaException { @@ -76,6 +103,30 @@ public class InventoryMethods implements GenericSource return stack.isEmpty() ? null : ItemData.fill( new HashMap<>(), stack ); } + /** + * Push items from one inventory to another connected one. + * + * This allows you to push an item in an inventory to another inventory on the same wired network. Both + * inventories must attached to wired modems which are connected via a cable. + * + * @param toName The name of the peripheral/inventory to push to. This is the string given to @{peripheral.wrap}, + * and displayed by the wired modem. + * @param fromSlot The slot in the current inventory to move items to. + * @param limit The maximum number of items to move. Defaults to the current stack limit. + * @param toSlot The slot in the target inventory to move to. If not given, the item will be inserted into any slot. + * @return The number of transferred items. + * @throws LuaException If the peripheral to transfer to doesn't exist or isn't an inventory. + * @throws LuaException If either source or destination slot is out of range. + * + * @cc.see peripheral.getName Allows you to get the name of a @{peripheral.wrap|wrapped} peripheral. + * @cc.usage Wrap two chests, and push an item from one to another. + *
{@code
+     * local chest_a = peripheral.wrap("minecraft:chest_0")
+     * local chest_b = peripheral.wrap("minecraft:chest_0")
+     *
+     * chest_a.pushItems(peripheral.getName(chest_b), 1)
+     * }
+ */ @LuaFunction( mainThread = true ) public static int pushItems( IItemHandler from, IComputerAccess computer, @@ -91,13 +142,37 @@ public class InventoryMethods implements GenericSource // Validate slots int actualLimit = limit.orElse( Integer.MAX_VALUE ); - if( actualLimit <= 0 ) throw new LuaException( "Limit must be > 0" ); assertBetween( fromSlot, 1, from.getSlots(), "From slot out of range (%s)" ); if( toSlot.isPresent() ) assertBetween( toSlot.get(), 1, to.getSlots(), "To slot out of range (%s)" ); + if( actualLimit <= 0 ) return 0; return moveItem( from, fromSlot - 1, to, toSlot.orElse( 0 ) - 1, actualLimit ); } + /** + * Pull items from a connected inventory into this one. + * + * This allows you to transfer items between inventories on the same wired network. Both this and the source + * inventory must attached to wired modems which are connected via a cable. + * + * @param fromName The name of the peripheral/inventory to pull from. This is the string given to @{peripheral.wrap}, + * and displayed by the wired modem. + * @param fromSlot The slot in the source inventory to move items from. + * @param limit The maximum number of items to move. Defaults to the current stack limit. + * @param toSlot The slot in current inventory to move to. If not given, the item will be inserted into any slot. + * @return The number of transferred items. + * @throws LuaException If the peripheral to transfer to doesn't exist or isn't an inventory. + * @throws LuaException If either source or destination slot is out of range. + * + * @cc.see peripheral.getName Allows you to get the name of a @{peripheral.wrap|wrapped} peripheral. + * @cc.usage Wrap two chests, and push an item from one to another. + *
{@code
+     * local chest_a = peripheral.wrap("minecraft:chest_0")
+     * local chest_b = peripheral.wrap("minecraft:chest_0")
+     *
+     * chest_a.pullItems(peripheral.getName(chest_b), 1)
+     * }
+ */ @LuaFunction( mainThread = true ) public static int pullItems( IItemHandler to, IComputerAccess computer, @@ -113,10 +188,10 @@ public class InventoryMethods implements GenericSource // Validate slots int actualLimit = limit.orElse( Integer.MAX_VALUE ); - if( actualLimit <= 0 ) throw new LuaException( "Limit must be > 0" ); assertBetween( fromSlot, 1, from.getSlots(), "From slot out of range (%s)" ); if( toSlot.isPresent() ) assertBetween( toSlot.get(), 1, to.getSlots(), "To slot out of range (%s)" ); + if( actualLimit <= 0 ) return 0; return moveItem( from, fromSlot - 1, to, toSlot.orElse( 0 ) - 1, actualLimit ); } From 5865e9c41a0140b9f1acdd2fb095353c467fbb45 Mon Sep 17 00:00:00 2001 From: SquidDev Date: Fri, 11 Dec 2020 21:41:29 +0000 Subject: [PATCH 28/38] Not sure what irritates me more The fact that I didn't run checkstyle before pushing or checkstyle itself. I wish this ran fast enough I could put it as a commit hook. --- .../shared/peripheral/generic/methods/EnergyMethods.java | 2 ++ .../peripheral/generic/methods/InventoryMethods.java | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/EnergyMethods.java b/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/EnergyMethods.java index 5df9a7993..5eab3f94f 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/EnergyMethods.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/EnergyMethods.java @@ -40,6 +40,7 @@ public class EnergyMethods implements GenericSource /** * Get the energy of this block. * + * @param energy The current energy storage. * @return The energy stored in this block, in FE. */ @LuaFunction( mainThread = true ) @@ -51,6 +52,7 @@ public class EnergyMethods implements GenericSource /** * Get the maximum amount of energy this block can store. * + * @param energy The current energy storage. * @return The energy capacity of this block. */ @LuaFunction( mainThread = true ) diff --git a/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/InventoryMethods.java b/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/InventoryMethods.java index 4c4864386..b8585f425 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/InventoryMethods.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/InventoryMethods.java @@ -50,6 +50,7 @@ public class InventoryMethods implements GenericSource /** * Get the size of this inventory. * + * @param inventory The current inventory. * @return The number of slots in this inventory. */ @LuaFunction( mainThread = true ) @@ -68,6 +69,7 @@ public class InventoryMethods implements GenericSource * The table is sparse, and so empty slots will be `nil` - it is recommended to loop over using `pairs` rather than * `ipairs`. * + * @param inventory The current inventory. * @return All items in this inventory. * @cc.treturn { (table|nil)... } All items in this inventory. */ @@ -88,6 +90,7 @@ public class InventoryMethods implements GenericSource /** * Get detailed information about an item. * + * @param inventory The current inventory. * @param slot The slot to get information about. * @return Information about the item in this slot, or {@code nil} if not present. * @throws LuaException If the slot is out of range. @@ -109,6 +112,8 @@ public class InventoryMethods implements GenericSource * This allows you to push an item in an inventory to another inventory on the same wired network. Both * inventories must attached to wired modems which are connected via a cable. * + * @param from Inventory to move items from. + * @param computer The current computer. * @param toName The name of the peripheral/inventory to push to. This is the string given to @{peripheral.wrap}, * and displayed by the wired modem. * @param fromSlot The slot in the current inventory to move items to. @@ -155,6 +160,8 @@ public class InventoryMethods implements GenericSource * This allows you to transfer items between inventories on the same wired network. Both this and the source * inventory must attached to wired modems which are connected via a cable. * + * @param to Inventory to move items to. + * @param computer The current computer. * @param fromName The name of the peripheral/inventory to pull from. This is the string given to @{peripheral.wrap}, * and displayed by the wired modem. * @param fromSlot The slot in the source inventory to move items from. From b97e950d86e4694409c01e507db34a87da85e452 Mon Sep 17 00:00:00 2001 From: TheWireLord Date: Sat, 12 Dec 2020 16:45:02 -0500 Subject: [PATCH 29/38] Added Numpad Enter Support - bios.lua Add the ability to use Numpad Enter and have it act just like normal Enter. (Just like the web-based emulator on the Tweaked.cc wiki) --- src/main/resources/data/computercraft/lua/bios.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/data/computercraft/lua/bios.lua b/src/main/resources/data/computercraft/lua/bios.lua index 4407dc99e..f0c364994 100644 --- a/src/main/resources/data/computercraft/lua/bios.lua +++ b/src/main/resources/data/computercraft/lua/bios.lua @@ -338,8 +338,8 @@ function read(_sReplaceChar, _tHistory, _fnComplete, _sDefault) redraw() elseif sEvent == "key" then - if param == keys.enter then - -- Enter + if param == keys.enter or param == keys.numPadEnter then + -- Enter/Numpad Enter if nCompletion then clear() uncomplete() From f5eb6ce03e0d9bbbf77130452afd4b49e758f7bd Mon Sep 17 00:00:00 2001 From: Jonathan Coates Date: Tue, 15 Dec 2020 09:31:12 +0000 Subject: [PATCH 30/38] Fix copy-paste error in inventory docs I'm a very silly squid. --- .../shared/peripheral/generic/methods/InventoryMethods.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/InventoryMethods.java b/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/InventoryMethods.java index b8585f425..c8a1c0749 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/InventoryMethods.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/InventoryMethods.java @@ -127,7 +127,7 @@ public class InventoryMethods implements GenericSource * @cc.usage Wrap two chests, and push an item from one to another. *
{@code
      * local chest_a = peripheral.wrap("minecraft:chest_0")
-     * local chest_b = peripheral.wrap("minecraft:chest_0")
+     * local chest_b = peripheral.wrap("minecraft:chest_1")
      *
      * chest_a.pushItems(peripheral.getName(chest_b), 1)
      * }
@@ -175,7 +175,7 @@ public class InventoryMethods implements GenericSource * @cc.usage Wrap two chests, and push an item from one to another. *
{@code
      * local chest_a = peripheral.wrap("minecraft:chest_0")
-     * local chest_b = peripheral.wrap("minecraft:chest_0")
+     * local chest_b = peripheral.wrap("minecraft:chest_1")
      *
      * chest_a.pullItems(peripheral.getName(chest_b), 1)
      * }
From 663859d2e5a97edefebf9ac36206903d7dd33a3e Mon Sep 17 00:00:00 2001 From: Jonathan Coates Date: Sun, 20 Dec 2020 19:57:31 +0000 Subject: [PATCH 31/38] Fix double URL decode Closes #613 --- .../core/apis/http/request/HttpRequestHandler.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/dan200/computercraft/core/apis/http/request/HttpRequestHandler.java b/src/main/java/dan200/computercraft/core/apis/http/request/HttpRequestHandler.java index fbd102be6..bebfdbea2 100644 --- a/src/main/java/dan200/computercraft/core/apis/http/request/HttpRequestHandler.java +++ b/src/main/java/dan200/computercraft/core/apis/http/request/HttpRequestHandler.java @@ -21,10 +21,8 @@ import io.netty.channel.SimpleChannelInboundHandler; import io.netty.handler.codec.http.*; import java.io.Closeable; -import java.io.UnsupportedEncodingException; import java.net.URI; import java.net.URISyntaxException; -import java.net.URLDecoder; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.HashMap; @@ -244,9 +242,9 @@ public final class HttpRequestHandler extends SimpleChannelInboundHandler Date: Wed, 23 Dec 2020 12:33:47 +0000 Subject: [PATCH 32/38] Fix overflow in os.epoch Closes #611 --- src/main/java/dan200/computercraft/core/apis/OSAPI.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/dan200/computercraft/core/apis/OSAPI.java b/src/main/java/dan200/computercraft/core/apis/OSAPI.java index b0752cdaa..f43d09539 100644 --- a/src/main/java/dan200/computercraft/core/apis/OSAPI.java +++ b/src/main/java/dan200/computercraft/core/apis/OSAPI.java @@ -412,7 +412,7 @@ public class OSAPI implements ILuaAPI // Get in-game epoch synchronized( m_alarms ) { - return m_day * 86400000 + (int) (m_time * 3600000.0f); + return m_day * 86400000L + (long) (m_time * 3600000.0); } default: throw new LuaException( "Unsupported operation" ); From e3a672099c1b5d2c06f9fe4d8ccd024fef0873a2 Mon Sep 17 00:00:00 2001 From: Jonathan Coates Date: Wed, 23 Dec 2020 15:46:27 +0000 Subject: [PATCH 33/38] Fix JEI integration with turtle/pocket upgrades - Remove incorrect impostor recipes for pocket computers. We were generating them from the list of turtle upgrades instead! - Fix JEI plugin not blocking impostor recipes as of the data-generator rewrite. --- .../minecraft/crafting_table.json | 35 ------------------- .../minecraft/diamond_axe.json | 35 ------------------- .../minecraft/diamond_hoe.json | 35 ------------------- .../minecraft/diamond_pickaxe.json | 35 ------------------- .../minecraft/diamond_shovel.json | 35 ------------------- .../minecraft/diamond_sword.json | 35 ------------------- .../minecraft/crafting_table.json | 35 ------------------- .../pocket_normal/minecraft/diamond_axe.json | 35 ------------------- .../pocket_normal/minecraft/diamond_hoe.json | 35 ------------------- .../minecraft/diamond_pickaxe.json | 35 ------------------- .../minecraft/diamond_shovel.json | 35 ------------------- .../minecraft/diamond_sword.json | 35 ------------------- .../minecraft/crafting_table.json | 19 ---------- .../minecraft/diamond_axe.json | 19 ---------- .../minecraft/diamond_hoe.json | 19 ---------- .../minecraft/diamond_pickaxe.json | 19 ---------- .../minecraft/diamond_shovel.json | 19 ---------- .../minecraft/diamond_sword.json | 19 ---------- .../minecraft/crafting_table.json | 19 ---------- .../pocket_normal/minecraft/diamond_axe.json | 19 ---------- .../pocket_normal/minecraft/diamond_hoe.json | 19 ---------- .../minecraft/diamond_pickaxe.json | 19 ---------- .../minecraft/diamond_shovel.json | 19 ---------- .../minecraft/diamond_sword.json | 19 ---------- .../dan200/computercraft/data/Recipes.java | 3 +- .../integration/jei/JEIComputerCraft.java | 7 ++-- 26 files changed, 7 insertions(+), 651 deletions(-) delete mode 100644 src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_advanced/minecraft/crafting_table.json delete mode 100644 src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_advanced/minecraft/diamond_axe.json delete mode 100644 src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_advanced/minecraft/diamond_hoe.json delete mode 100644 src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_advanced/minecraft/diamond_pickaxe.json delete mode 100644 src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_advanced/minecraft/diamond_shovel.json delete mode 100644 src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_advanced/minecraft/diamond_sword.json delete mode 100644 src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_normal/minecraft/crafting_table.json delete mode 100644 src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_normal/minecraft/diamond_axe.json delete mode 100644 src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_normal/minecraft/diamond_hoe.json delete mode 100644 src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_normal/minecraft/diamond_pickaxe.json delete mode 100644 src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_normal/minecraft/diamond_shovel.json delete mode 100644 src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_normal/minecraft/diamond_sword.json delete mode 100644 src/generated/resources/data/computercraft/recipes/pocket_advanced/minecraft/crafting_table.json delete mode 100644 src/generated/resources/data/computercraft/recipes/pocket_advanced/minecraft/diamond_axe.json delete mode 100644 src/generated/resources/data/computercraft/recipes/pocket_advanced/minecraft/diamond_hoe.json delete mode 100644 src/generated/resources/data/computercraft/recipes/pocket_advanced/minecraft/diamond_pickaxe.json delete mode 100644 src/generated/resources/data/computercraft/recipes/pocket_advanced/minecraft/diamond_shovel.json delete mode 100644 src/generated/resources/data/computercraft/recipes/pocket_advanced/minecraft/diamond_sword.json delete mode 100644 src/generated/resources/data/computercraft/recipes/pocket_normal/minecraft/crafting_table.json delete mode 100644 src/generated/resources/data/computercraft/recipes/pocket_normal/minecraft/diamond_axe.json delete mode 100644 src/generated/resources/data/computercraft/recipes/pocket_normal/minecraft/diamond_hoe.json delete mode 100644 src/generated/resources/data/computercraft/recipes/pocket_normal/minecraft/diamond_pickaxe.json delete mode 100644 src/generated/resources/data/computercraft/recipes/pocket_normal/minecraft/diamond_shovel.json delete mode 100644 src/generated/resources/data/computercraft/recipes/pocket_normal/minecraft/diamond_sword.json diff --git a/src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_advanced/minecraft/crafting_table.json b/src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_advanced/minecraft/crafting_table.json deleted file mode 100644 index 112ba7081..000000000 --- a/src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_advanced/minecraft/crafting_table.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "parent": "minecraft:recipes/root", - "rewards": { - "recipes": [ - "computercraft:pocket_advanced/minecraft/crafting_table" - ] - }, - "criteria": { - "has_items": { - "trigger": "minecraft:inventory_changed", - "conditions": { - "items": [ - { - "item": "computercraft:pocket_computer_advanced" - }, - { - "item": "minecraft:crafting_table" - } - ] - } - }, - "has_the_recipe": { - "trigger": "minecraft:recipe_unlocked", - "conditions": { - "recipe": "computercraft:pocket_advanced/minecraft/crafting_table" - } - } - }, - "requirements": [ - [ - "has_items", - "has_the_recipe" - ] - ] -} \ No newline at end of file diff --git a/src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_advanced/minecraft/diamond_axe.json b/src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_advanced/minecraft/diamond_axe.json deleted file mode 100644 index 7b5c315e4..000000000 --- a/src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_advanced/minecraft/diamond_axe.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "parent": "minecraft:recipes/root", - "rewards": { - "recipes": [ - "computercraft:pocket_advanced/minecraft/diamond_axe" - ] - }, - "criteria": { - "has_items": { - "trigger": "minecraft:inventory_changed", - "conditions": { - "items": [ - { - "item": "computercraft:pocket_computer_advanced" - }, - { - "item": "minecraft:diamond_axe" - } - ] - } - }, - "has_the_recipe": { - "trigger": "minecraft:recipe_unlocked", - "conditions": { - "recipe": "computercraft:pocket_advanced/minecraft/diamond_axe" - } - } - }, - "requirements": [ - [ - "has_items", - "has_the_recipe" - ] - ] -} \ No newline at end of file diff --git a/src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_advanced/minecraft/diamond_hoe.json b/src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_advanced/minecraft/diamond_hoe.json deleted file mode 100644 index 9f5872d9f..000000000 --- a/src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_advanced/minecraft/diamond_hoe.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "parent": "minecraft:recipes/root", - "rewards": { - "recipes": [ - "computercraft:pocket_advanced/minecraft/diamond_hoe" - ] - }, - "criteria": { - "has_items": { - "trigger": "minecraft:inventory_changed", - "conditions": { - "items": [ - { - "item": "computercraft:pocket_computer_advanced" - }, - { - "item": "minecraft:diamond_hoe" - } - ] - } - }, - "has_the_recipe": { - "trigger": "minecraft:recipe_unlocked", - "conditions": { - "recipe": "computercraft:pocket_advanced/minecraft/diamond_hoe" - } - } - }, - "requirements": [ - [ - "has_items", - "has_the_recipe" - ] - ] -} \ No newline at end of file diff --git a/src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_advanced/minecraft/diamond_pickaxe.json b/src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_advanced/minecraft/diamond_pickaxe.json deleted file mode 100644 index 7e1930b03..000000000 --- a/src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_advanced/minecraft/diamond_pickaxe.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "parent": "minecraft:recipes/root", - "rewards": { - "recipes": [ - "computercraft:pocket_advanced/minecraft/diamond_pickaxe" - ] - }, - "criteria": { - "has_items": { - "trigger": "minecraft:inventory_changed", - "conditions": { - "items": [ - { - "item": "computercraft:pocket_computer_advanced" - }, - { - "item": "minecraft:diamond_pickaxe" - } - ] - } - }, - "has_the_recipe": { - "trigger": "minecraft:recipe_unlocked", - "conditions": { - "recipe": "computercraft:pocket_advanced/minecraft/diamond_pickaxe" - } - } - }, - "requirements": [ - [ - "has_items", - "has_the_recipe" - ] - ] -} \ No newline at end of file diff --git a/src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_advanced/minecraft/diamond_shovel.json b/src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_advanced/minecraft/diamond_shovel.json deleted file mode 100644 index 05222ce97..000000000 --- a/src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_advanced/minecraft/diamond_shovel.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "parent": "minecraft:recipes/root", - "rewards": { - "recipes": [ - "computercraft:pocket_advanced/minecraft/diamond_shovel" - ] - }, - "criteria": { - "has_items": { - "trigger": "minecraft:inventory_changed", - "conditions": { - "items": [ - { - "item": "computercraft:pocket_computer_advanced" - }, - { - "item": "minecraft:diamond_shovel" - } - ] - } - }, - "has_the_recipe": { - "trigger": "minecraft:recipe_unlocked", - "conditions": { - "recipe": "computercraft:pocket_advanced/minecraft/diamond_shovel" - } - } - }, - "requirements": [ - [ - "has_items", - "has_the_recipe" - ] - ] -} \ No newline at end of file diff --git a/src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_advanced/minecraft/diamond_sword.json b/src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_advanced/minecraft/diamond_sword.json deleted file mode 100644 index 413e0375d..000000000 --- a/src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_advanced/minecraft/diamond_sword.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "parent": "minecraft:recipes/root", - "rewards": { - "recipes": [ - "computercraft:pocket_advanced/minecraft/diamond_sword" - ] - }, - "criteria": { - "has_items": { - "trigger": "minecraft:inventory_changed", - "conditions": { - "items": [ - { - "item": "computercraft:pocket_computer_advanced" - }, - { - "item": "minecraft:diamond_sword" - } - ] - } - }, - "has_the_recipe": { - "trigger": "minecraft:recipe_unlocked", - "conditions": { - "recipe": "computercraft:pocket_advanced/minecraft/diamond_sword" - } - } - }, - "requirements": [ - [ - "has_items", - "has_the_recipe" - ] - ] -} \ No newline at end of file diff --git a/src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_normal/minecraft/crafting_table.json b/src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_normal/minecraft/crafting_table.json deleted file mode 100644 index c507d2563..000000000 --- a/src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_normal/minecraft/crafting_table.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "parent": "minecraft:recipes/root", - "rewards": { - "recipes": [ - "computercraft:pocket_normal/minecraft/crafting_table" - ] - }, - "criteria": { - "has_items": { - "trigger": "minecraft:inventory_changed", - "conditions": { - "items": [ - { - "item": "computercraft:pocket_computer_normal" - }, - { - "item": "minecraft:crafting_table" - } - ] - } - }, - "has_the_recipe": { - "trigger": "minecraft:recipe_unlocked", - "conditions": { - "recipe": "computercraft:pocket_normal/minecraft/crafting_table" - } - } - }, - "requirements": [ - [ - "has_items", - "has_the_recipe" - ] - ] -} \ No newline at end of file diff --git a/src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_normal/minecraft/diamond_axe.json b/src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_normal/minecraft/diamond_axe.json deleted file mode 100644 index a14901a3e..000000000 --- a/src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_normal/minecraft/diamond_axe.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "parent": "minecraft:recipes/root", - "rewards": { - "recipes": [ - "computercraft:pocket_normal/minecraft/diamond_axe" - ] - }, - "criteria": { - "has_items": { - "trigger": "minecraft:inventory_changed", - "conditions": { - "items": [ - { - "item": "computercraft:pocket_computer_normal" - }, - { - "item": "minecraft:diamond_axe" - } - ] - } - }, - "has_the_recipe": { - "trigger": "minecraft:recipe_unlocked", - "conditions": { - "recipe": "computercraft:pocket_normal/minecraft/diamond_axe" - } - } - }, - "requirements": [ - [ - "has_items", - "has_the_recipe" - ] - ] -} \ No newline at end of file diff --git a/src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_normal/minecraft/diamond_hoe.json b/src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_normal/minecraft/diamond_hoe.json deleted file mode 100644 index 5dba7dcd6..000000000 --- a/src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_normal/minecraft/diamond_hoe.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "parent": "minecraft:recipes/root", - "rewards": { - "recipes": [ - "computercraft:pocket_normal/minecraft/diamond_hoe" - ] - }, - "criteria": { - "has_items": { - "trigger": "minecraft:inventory_changed", - "conditions": { - "items": [ - { - "item": "computercraft:pocket_computer_normal" - }, - { - "item": "minecraft:diamond_hoe" - } - ] - } - }, - "has_the_recipe": { - "trigger": "minecraft:recipe_unlocked", - "conditions": { - "recipe": "computercraft:pocket_normal/minecraft/diamond_hoe" - } - } - }, - "requirements": [ - [ - "has_items", - "has_the_recipe" - ] - ] -} \ No newline at end of file diff --git a/src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_normal/minecraft/diamond_pickaxe.json b/src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_normal/minecraft/diamond_pickaxe.json deleted file mode 100644 index 06a10b8ec..000000000 --- a/src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_normal/minecraft/diamond_pickaxe.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "parent": "minecraft:recipes/root", - "rewards": { - "recipes": [ - "computercraft:pocket_normal/minecraft/diamond_pickaxe" - ] - }, - "criteria": { - "has_items": { - "trigger": "minecraft:inventory_changed", - "conditions": { - "items": [ - { - "item": "computercraft:pocket_computer_normal" - }, - { - "item": "minecraft:diamond_pickaxe" - } - ] - } - }, - "has_the_recipe": { - "trigger": "minecraft:recipe_unlocked", - "conditions": { - "recipe": "computercraft:pocket_normal/minecraft/diamond_pickaxe" - } - } - }, - "requirements": [ - [ - "has_items", - "has_the_recipe" - ] - ] -} \ No newline at end of file diff --git a/src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_normal/minecraft/diamond_shovel.json b/src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_normal/minecraft/diamond_shovel.json deleted file mode 100644 index 22ccd7e60..000000000 --- a/src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_normal/minecraft/diamond_shovel.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "parent": "minecraft:recipes/root", - "rewards": { - "recipes": [ - "computercraft:pocket_normal/minecraft/diamond_shovel" - ] - }, - "criteria": { - "has_items": { - "trigger": "minecraft:inventory_changed", - "conditions": { - "items": [ - { - "item": "computercraft:pocket_computer_normal" - }, - { - "item": "minecraft:diamond_shovel" - } - ] - } - }, - "has_the_recipe": { - "trigger": "minecraft:recipe_unlocked", - "conditions": { - "recipe": "computercraft:pocket_normal/minecraft/diamond_shovel" - } - } - }, - "requirements": [ - [ - "has_items", - "has_the_recipe" - ] - ] -} \ No newline at end of file diff --git a/src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_normal/minecraft/diamond_sword.json b/src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_normal/minecraft/diamond_sword.json deleted file mode 100644 index 74378a20c..000000000 --- a/src/generated/resources/data/computercraft/advancements/recipes/computercraft/pocket_normal/minecraft/diamond_sword.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "parent": "minecraft:recipes/root", - "rewards": { - "recipes": [ - "computercraft:pocket_normal/minecraft/diamond_sword" - ] - }, - "criteria": { - "has_items": { - "trigger": "minecraft:inventory_changed", - "conditions": { - "items": [ - { - "item": "computercraft:pocket_computer_normal" - }, - { - "item": "minecraft:diamond_sword" - } - ] - } - }, - "has_the_recipe": { - "trigger": "minecraft:recipe_unlocked", - "conditions": { - "recipe": "computercraft:pocket_normal/minecraft/diamond_sword" - } - } - }, - "requirements": [ - [ - "has_items", - "has_the_recipe" - ] - ] -} \ No newline at end of file diff --git a/src/generated/resources/data/computercraft/recipes/pocket_advanced/minecraft/crafting_table.json b/src/generated/resources/data/computercraft/recipes/pocket_advanced/minecraft/crafting_table.json deleted file mode 100644 index 0cd065680..000000000 --- a/src/generated/resources/data/computercraft/recipes/pocket_advanced/minecraft/crafting_table.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "type": "computercraft:impostor_shaped", - "group": "computercraft:pocket_advanced", - "pattern": [ - "#", - "P" - ], - "key": { - "#": { - "item": "computercraft:pocket_computer_advanced" - }, - "P": { - "item": "minecraft:crafting_table" - } - }, - "result": { - "item": "computercraft:pocket_computer_advanced" - } -} \ No newline at end of file diff --git a/src/generated/resources/data/computercraft/recipes/pocket_advanced/minecraft/diamond_axe.json b/src/generated/resources/data/computercraft/recipes/pocket_advanced/minecraft/diamond_axe.json deleted file mode 100644 index 7b8fa8a24..000000000 --- a/src/generated/resources/data/computercraft/recipes/pocket_advanced/minecraft/diamond_axe.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "type": "computercraft:impostor_shaped", - "group": "computercraft:pocket_advanced", - "pattern": [ - "#", - "P" - ], - "key": { - "#": { - "item": "computercraft:pocket_computer_advanced" - }, - "P": { - "item": "minecraft:diamond_axe" - } - }, - "result": { - "item": "computercraft:pocket_computer_advanced" - } -} \ No newline at end of file diff --git a/src/generated/resources/data/computercraft/recipes/pocket_advanced/minecraft/diamond_hoe.json b/src/generated/resources/data/computercraft/recipes/pocket_advanced/minecraft/diamond_hoe.json deleted file mode 100644 index 9514a59cd..000000000 --- a/src/generated/resources/data/computercraft/recipes/pocket_advanced/minecraft/diamond_hoe.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "type": "computercraft:impostor_shaped", - "group": "computercraft:pocket_advanced", - "pattern": [ - "#", - "P" - ], - "key": { - "#": { - "item": "computercraft:pocket_computer_advanced" - }, - "P": { - "item": "minecraft:diamond_hoe" - } - }, - "result": { - "item": "computercraft:pocket_computer_advanced" - } -} \ No newline at end of file diff --git a/src/generated/resources/data/computercraft/recipes/pocket_advanced/minecraft/diamond_pickaxe.json b/src/generated/resources/data/computercraft/recipes/pocket_advanced/minecraft/diamond_pickaxe.json deleted file mode 100644 index e28008623..000000000 --- a/src/generated/resources/data/computercraft/recipes/pocket_advanced/minecraft/diamond_pickaxe.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "type": "computercraft:impostor_shaped", - "group": "computercraft:pocket_advanced", - "pattern": [ - "#", - "P" - ], - "key": { - "#": { - "item": "computercraft:pocket_computer_advanced" - }, - "P": { - "item": "minecraft:diamond_pickaxe" - } - }, - "result": { - "item": "computercraft:pocket_computer_advanced" - } -} \ No newline at end of file diff --git a/src/generated/resources/data/computercraft/recipes/pocket_advanced/minecraft/diamond_shovel.json b/src/generated/resources/data/computercraft/recipes/pocket_advanced/minecraft/diamond_shovel.json deleted file mode 100644 index b0ddf3016..000000000 --- a/src/generated/resources/data/computercraft/recipes/pocket_advanced/minecraft/diamond_shovel.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "type": "computercraft:impostor_shaped", - "group": "computercraft:pocket_advanced", - "pattern": [ - "#", - "P" - ], - "key": { - "#": { - "item": "computercraft:pocket_computer_advanced" - }, - "P": { - "item": "minecraft:diamond_shovel" - } - }, - "result": { - "item": "computercraft:pocket_computer_advanced" - } -} \ No newline at end of file diff --git a/src/generated/resources/data/computercraft/recipes/pocket_advanced/minecraft/diamond_sword.json b/src/generated/resources/data/computercraft/recipes/pocket_advanced/minecraft/diamond_sword.json deleted file mode 100644 index cea0b2a0f..000000000 --- a/src/generated/resources/data/computercraft/recipes/pocket_advanced/minecraft/diamond_sword.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "type": "computercraft:impostor_shaped", - "group": "computercraft:pocket_advanced", - "pattern": [ - "#", - "P" - ], - "key": { - "#": { - "item": "computercraft:pocket_computer_advanced" - }, - "P": { - "item": "minecraft:diamond_sword" - } - }, - "result": { - "item": "computercraft:pocket_computer_advanced" - } -} \ No newline at end of file diff --git a/src/generated/resources/data/computercraft/recipes/pocket_normal/minecraft/crafting_table.json b/src/generated/resources/data/computercraft/recipes/pocket_normal/minecraft/crafting_table.json deleted file mode 100644 index dc1ddd884..000000000 --- a/src/generated/resources/data/computercraft/recipes/pocket_normal/minecraft/crafting_table.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "type": "computercraft:impostor_shaped", - "group": "computercraft:pocket_normal", - "pattern": [ - "#", - "P" - ], - "key": { - "#": { - "item": "computercraft:pocket_computer_normal" - }, - "P": { - "item": "minecraft:crafting_table" - } - }, - "result": { - "item": "computercraft:pocket_computer_normal" - } -} \ No newline at end of file diff --git a/src/generated/resources/data/computercraft/recipes/pocket_normal/minecraft/diamond_axe.json b/src/generated/resources/data/computercraft/recipes/pocket_normal/minecraft/diamond_axe.json deleted file mode 100644 index 686d9d890..000000000 --- a/src/generated/resources/data/computercraft/recipes/pocket_normal/minecraft/diamond_axe.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "type": "computercraft:impostor_shaped", - "group": "computercraft:pocket_normal", - "pattern": [ - "#", - "P" - ], - "key": { - "#": { - "item": "computercraft:pocket_computer_normal" - }, - "P": { - "item": "minecraft:diamond_axe" - } - }, - "result": { - "item": "computercraft:pocket_computer_normal" - } -} \ No newline at end of file diff --git a/src/generated/resources/data/computercraft/recipes/pocket_normal/minecraft/diamond_hoe.json b/src/generated/resources/data/computercraft/recipes/pocket_normal/minecraft/diamond_hoe.json deleted file mode 100644 index 905a2640a..000000000 --- a/src/generated/resources/data/computercraft/recipes/pocket_normal/minecraft/diamond_hoe.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "type": "computercraft:impostor_shaped", - "group": "computercraft:pocket_normal", - "pattern": [ - "#", - "P" - ], - "key": { - "#": { - "item": "computercraft:pocket_computer_normal" - }, - "P": { - "item": "minecraft:diamond_hoe" - } - }, - "result": { - "item": "computercraft:pocket_computer_normal" - } -} \ No newline at end of file diff --git a/src/generated/resources/data/computercraft/recipes/pocket_normal/minecraft/diamond_pickaxe.json b/src/generated/resources/data/computercraft/recipes/pocket_normal/minecraft/diamond_pickaxe.json deleted file mode 100644 index 200d15862..000000000 --- a/src/generated/resources/data/computercraft/recipes/pocket_normal/minecraft/diamond_pickaxe.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "type": "computercraft:impostor_shaped", - "group": "computercraft:pocket_normal", - "pattern": [ - "#", - "P" - ], - "key": { - "#": { - "item": "computercraft:pocket_computer_normal" - }, - "P": { - "item": "minecraft:diamond_pickaxe" - } - }, - "result": { - "item": "computercraft:pocket_computer_normal" - } -} \ No newline at end of file diff --git a/src/generated/resources/data/computercraft/recipes/pocket_normal/minecraft/diamond_shovel.json b/src/generated/resources/data/computercraft/recipes/pocket_normal/minecraft/diamond_shovel.json deleted file mode 100644 index fcae256c7..000000000 --- a/src/generated/resources/data/computercraft/recipes/pocket_normal/minecraft/diamond_shovel.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "type": "computercraft:impostor_shaped", - "group": "computercraft:pocket_normal", - "pattern": [ - "#", - "P" - ], - "key": { - "#": { - "item": "computercraft:pocket_computer_normal" - }, - "P": { - "item": "minecraft:diamond_shovel" - } - }, - "result": { - "item": "computercraft:pocket_computer_normal" - } -} \ No newline at end of file diff --git a/src/generated/resources/data/computercraft/recipes/pocket_normal/minecraft/diamond_sword.json b/src/generated/resources/data/computercraft/recipes/pocket_normal/minecraft/diamond_sword.json deleted file mode 100644 index 564dbf7e5..000000000 --- a/src/generated/resources/data/computercraft/recipes/pocket_normal/minecraft/diamond_sword.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "type": "computercraft:impostor_shaped", - "group": "computercraft:pocket_normal", - "pattern": [ - "#", - "P" - ], - "key": { - "#": { - "item": "computercraft:pocket_computer_normal" - }, - "P": { - "item": "minecraft:diamond_sword" - } - }, - "result": { - "item": "computercraft:pocket_computer_normal" - } -} \ No newline at end of file diff --git a/src/main/java/dan200/computercraft/data/Recipes.java b/src/main/java/dan200/computercraft/data/Recipes.java index a86ac212e..d7dc75d78 100644 --- a/src/main/java/dan200/computercraft/data/Recipes.java +++ b/src/main/java/dan200/computercraft/data/Recipes.java @@ -8,6 +8,7 @@ package dan200.computercraft.data; import dan200.computercraft.ComputerCraft; import dan200.computercraft.data.Tags.CCTags; +import dan200.computercraft.shared.PocketUpgrades; import dan200.computercraft.shared.Registry; import dan200.computercraft.shared.TurtleUpgrades; import dan200.computercraft.shared.computer.core.ComputerFamily; @@ -117,7 +118,7 @@ public class Recipes extends RecipeProvider String nameId = family.name().toLowerCase( Locale.ROOT ); - TurtleUpgrades.getVanillaUpgrades().forEach( upgrade -> { + PocketUpgrades.getVanillaUpgrades().forEach( upgrade -> { ItemStack result = PocketComputerItemFactory.create( -1, null, -1, family, null ); ShapedRecipeBuilder .shapedRecipe( result.getItem() ) diff --git a/src/main/java/dan200/computercraft/shared/integration/jei/JEIComputerCraft.java b/src/main/java/dan200/computercraft/shared/integration/jei/JEIComputerCraft.java index c7d99cebb..45e0e380b 100644 --- a/src/main/java/dan200/computercraft/shared/integration/jei/JEIComputerCraft.java +++ b/src/main/java/dan200/computercraft/shared/integration/jei/JEIComputerCraft.java @@ -97,8 +97,11 @@ public class JEIComputerCraft implements IModPlugin { if( !(wrapper instanceof IRecipe) ) continue; ResourceLocation id = ((IRecipe) wrapper).getId(); - if( id.getNamespace().equals( ComputerCraft.MOD_ID ) - && (id.getPath().startsWith( "generated/turtle_" ) || id.getPath().startsWith( "generated/pocket_" )) ) + if( !id.getNamespace().equals( ComputerCraft.MOD_ID ) ) continue; + + String path = id.getPath(); + if( path.startsWith( "turtle_normal/" ) || path.startsWith( "turtle_advanced/" ) + || path.startsWith( "pocket_normal/" ) || path.startsWith( "pocket_advanced/" ) ) { registry.hideRecipe( wrapper, VanillaRecipeCategoryUid.CRAFTING ); } From 2f0cae0bc1b038ac092bafa7f65a317537203cd8 Mon Sep 17 00:00:00 2001 From: Jonathan Coates Date: Wed, 23 Dec 2020 15:52:33 +0000 Subject: [PATCH 34/38] Make upgrade recipe requirements a little more lax - Move some common upgrade code to IUpgradeBase. 99% sure this this preserves binary compatibility (on the JVM at least). - Instead of requiring the share tag to match, allow upgrades to specify their own predicate. IMO this is a little ugly, but required to fix #614 as other mods chuck their own NBT on items. --- .../computercraft/api/IUpgradeBase.java | 81 +++++++++++++++++++ .../api/pocket/IPocketUpgrade.java | 47 +---------- .../api/turtle/ITurtleUpgrade.java | 38 +-------- .../computercraft/shared/PocketUpgrades.java | 3 +- .../computercraft/shared/TurtleUpgrades.java | 3 +- .../integration/jei/RecipeResolver.java | 37 +++------ .../shared/turtle/upgrades/TurtleTool.java | 20 +++++ .../shared/util/InventoryUtil.java | 30 ------- 8 files changed, 121 insertions(+), 138 deletions(-) create mode 100644 src/main/java/dan200/computercraft/api/IUpgradeBase.java diff --git a/src/main/java/dan200/computercraft/api/IUpgradeBase.java b/src/main/java/dan200/computercraft/api/IUpgradeBase.java new file mode 100644 index 000000000..03a90571e --- /dev/null +++ b/src/main/java/dan200/computercraft/api/IUpgradeBase.java @@ -0,0 +1,81 @@ +package dan200.computercraft.api; + +import dan200.computercraft.api.pocket.IPocketUpgrade; +import dan200.computercraft.api.turtle.ITurtleUpgrade; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.util.ResourceLocation; + +import javax.annotation.Nonnull; + +/** + * Common functionality between {@link ITurtleUpgrade} and {@link IPocketUpgrade}. + */ +public interface IUpgradeBase +{ + /** + * Gets a unique identifier representing this type of turtle upgrade. eg: "computercraft:wireless_modem" + * or "my_mod:my_upgrade". + * + * You should use a unique resource domain to ensure this upgrade is uniquely identified. + * The upgrade will fail registration if an already used ID is specified. + * + * @return The unique ID for this upgrade. + */ + @Nonnull + ResourceLocation getUpgradeID(); + + /** + * Return an unlocalised string to describe this type of computer in item names. + * + * Examples of built-in adjectives are "Wireless", "Mining" and "Crafty". + * + * @return The localisation key for this upgrade's adjective. + */ + @Nonnull + String getUnlocalisedAdjective(); + + /** + * Return an item stack representing the type of item that a computer must be crafted + * with to create a version which holds this upgrade. This item stack is also used + * to determine the upgrade given by {@code turtle.equipLeft()} or {@code pocket.equipBack()} + * + * This should be constant over a session (or at least a datapack reload). It is recommended + * that you cache the stack too, in order to prevent constructing it every time the method + * is called. + * + * @return The item stack to craft with, or {@link ItemStack#EMPTY} if it cannot be crafted. + */ + @Nonnull + ItemStack getCraftingItem(); + + /** + * Determine if an item is suitable for being used for this upgrade. + * + * When un-equipping an upgrade, we return {@link #getCraftingItem()} rather than + * the original stack. In order to prevent people losing items with enchantments (or + * repairing items with non-0 damage), we impose additional checks on the item. + * + * The default check requires that any non-capability NBT is exactly the same as the + * crafting item, but this may be relaxed for your upgrade. + * + * @param stack The stack to check. This is guaranteed to be non-empty and have the same item as + * {@link #getCraftingItem()}. + * @return If this stack may be used to equip this upgrade. + * @see net.minecraftforge.common.crafting.NBTIngredient#test(ItemStack) For the implementation of the default + * check. + */ + default boolean isItemSuitable( @Nonnull ItemStack stack ) + { + ItemStack crafting = getCraftingItem(); + + // A more expanded form of ItemStack.areShareTagsEqual, but allowing an empty tag to be equal to a + // null one. + CompoundNBT shareTag = stack.getItem().getShareTag( stack ); + CompoundNBT craftingShareTag = crafting.getItem().getShareTag( crafting ); + if( shareTag == craftingShareTag ) return true; + if( shareTag == null ) return craftingShareTag.isEmpty(); + if( craftingShareTag == null ) return shareTag.isEmpty(); + return shareTag.equals( craftingShareTag ); + } +} diff --git a/src/main/java/dan200/computercraft/api/pocket/IPocketUpgrade.java b/src/main/java/dan200/computercraft/api/pocket/IPocketUpgrade.java index 638f95cc7..c0b761ef2 100644 --- a/src/main/java/dan200/computercraft/api/pocket/IPocketUpgrade.java +++ b/src/main/java/dan200/computercraft/api/pocket/IPocketUpgrade.java @@ -6,10 +6,8 @@ package dan200.computercraft.api.pocket; import dan200.computercraft.api.ComputerCraftAPI; +import dan200.computercraft.api.IUpgradeBase; import dan200.computercraft.api.peripheral.IPeripheral; -import dan200.computercraft.api.turtle.ITurtleUpgrade; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import javax.annotation.Nonnull; @@ -18,49 +16,10 @@ import javax.annotation.Nullable; /** * Additional peripherals for pocket computers. * - * This is similar to {@link ITurtleUpgrade}. + * @see ComputerCraftAPI#registerPocketUpgrade(IPocketUpgrade) */ -public interface IPocketUpgrade +public interface IPocketUpgrade extends IUpgradeBase { - - /** - * Gets a unique identifier representing this type of turtle upgrade. eg: "computercraft:wireless_modem" or - * "my_mod:my_upgrade". - * - * You should use a unique resource domain to ensure this upgrade is uniquely identified. The upgrade will fail - * registration if an already used ID is specified. - * - * @return The upgrade's id. - * @see IPocketUpgrade#getUpgradeID() - * @see ComputerCraftAPI#registerPocketUpgrade(IPocketUpgrade) - */ - @Nonnull - ResourceLocation getUpgradeID(); - - /** - * Return an unlocalised string to describe the type of pocket computer this upgrade provides. - * - * An example of a built-in adjectives is "Wireless" - this is converted to "Wireless Pocket Computer". - * - * @return The unlocalised adjective. - * @see ITurtleUpgrade#getUnlocalisedAdjective() - */ - @Nonnull - String getUnlocalisedAdjective(); - - /** - * Return an item stack representing the type of item that a pocket computer must be crafted with to create a - * pocket computer which holds this upgrade. This item stack is also used to determine the upgrade given by - * {@code pocket.equip()}/{@code pocket.unequip()}. - * - * Ideally this should be constant over a session. It is recommended that you cache - * the item too, in order to prevent constructing it every time the method is called. - * - * @return The item stack used for crafting. This can be {@link ItemStack#EMPTY} if crafting is disabled. - */ - @Nonnull - ItemStack getCraftingItem(); - /** * Creates a peripheral for the pocket computer. * diff --git a/src/main/java/dan200/computercraft/api/turtle/ITurtleUpgrade.java b/src/main/java/dan200/computercraft/api/turtle/ITurtleUpgrade.java index 70d80e38c..76e53919e 100644 --- a/src/main/java/dan200/computercraft/api/turtle/ITurtleUpgrade.java +++ b/src/main/java/dan200/computercraft/api/turtle/ITurtleUpgrade.java @@ -6,6 +6,7 @@ package dan200.computercraft.api.turtle; import dan200.computercraft.api.ComputerCraftAPI; +import dan200.computercraft.api.IUpgradeBase; import dan200.computercraft.api.client.TransformedModel; import dan200.computercraft.api.peripheral.IPeripheral; import dan200.computercraft.api.turtle.event.TurtleAttackEvent; @@ -13,7 +14,6 @@ import dan200.computercraft.api.turtle.event.TurtleBlockEvent; import net.minecraft.client.renderer.model.ModelResourceLocation; import net.minecraft.item.ItemStack; import net.minecraft.util.Direction; -import net.minecraft.util.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.event.entity.player.AttackEntityEvent; @@ -28,29 +28,8 @@ import javax.annotation.Nullable; * * @see ComputerCraftAPI#registerTurtleUpgrade(ITurtleUpgrade) */ -public interface ITurtleUpgrade +public interface ITurtleUpgrade extends IUpgradeBase { - /** - * Gets a unique identifier representing this type of turtle upgrade. eg: "computercraft:wireless_modem" or "my_mod:my_upgrade". - * You should use a unique resource domain to ensure this upgrade is uniquely identified. - * The turtle will fail registration if an already used ID is specified. - * - * @return The unique ID for this upgrade. - * @see ComputerCraftAPI#registerTurtleUpgrade(ITurtleUpgrade) - */ - @Nonnull - ResourceLocation getUpgradeID(); - - /** - * Return an unlocalised string to describe this type of turtle in turtle item names. - * - * Examples of built-in adjectives are "Wireless", "Mining" and "Crafty". - * - * @return The localisation key for this upgrade's adjective. - */ - @Nonnull - String getUnlocalisedAdjective(); - /** * Return whether this turtle adds a tool or a peripheral to the turtle. * @@ -60,19 +39,6 @@ public interface ITurtleUpgrade @Nonnull TurtleUpgradeType getType(); - /** - * Return an item stack representing the type of item that a turtle must be crafted - * with to create a turtle which holds this upgrade. This item stack is also used - * to determine the upgrade given by {@code turtle.equip()} - * - * Ideally this should be constant over a session. It is recommended that you cache - * the item too, in order to prevent constructing it every time the method is called. - * - * @return The item stack to craft with, or {@link ItemStack#EMPTY} if it cannot be crafted. - */ - @Nonnull - ItemStack getCraftingItem(); - /** * Will only be called for peripheral upgrades. Creates a peripheral for a turtle being placed using this upgrade. * diff --git a/src/main/java/dan200/computercraft/shared/PocketUpgrades.java b/src/main/java/dan200/computercraft/shared/PocketUpgrades.java index f46a87820..58494b618 100644 --- a/src/main/java/dan200/computercraft/shared/PocketUpgrades.java +++ b/src/main/java/dan200/computercraft/shared/PocketUpgrades.java @@ -7,7 +7,6 @@ package dan200.computercraft.shared; import dan200.computercraft.ComputerCraft; import dan200.computercraft.api.pocket.IPocketUpgrade; -import dan200.computercraft.shared.util.InventoryUtil; import net.minecraft.item.ItemStack; import net.minecraftforge.fml.ModContainer; import net.minecraftforge.fml.ModLoadingContext; @@ -55,7 +54,7 @@ public final class PocketUpgrades for( IPocketUpgrade upgrade : upgrades.values() ) { ItemStack craftingStack = upgrade.getCraftingItem(); - if( !craftingStack.isEmpty() && InventoryUtil.areItemsSimilar( stack, craftingStack ) ) + if( !craftingStack.isEmpty() && craftingStack.getItem() == stack.getItem() && upgrade.isItemSuitable( stack ) ) { return upgrade; } diff --git a/src/main/java/dan200/computercraft/shared/TurtleUpgrades.java b/src/main/java/dan200/computercraft/shared/TurtleUpgrades.java index d9e4bc30f..76aa1c8a4 100644 --- a/src/main/java/dan200/computercraft/shared/TurtleUpgrades.java +++ b/src/main/java/dan200/computercraft/shared/TurtleUpgrades.java @@ -8,7 +8,6 @@ package dan200.computercraft.shared; import dan200.computercraft.ComputerCraft; import dan200.computercraft.api.turtle.ITurtleUpgrade; import dan200.computercraft.shared.computer.core.ComputerFamily; -import dan200.computercraft.shared.util.InventoryUtil; import net.minecraft.item.ItemStack; import net.minecraftforge.fml.ModLoadingContext; @@ -83,7 +82,7 @@ public final class TurtleUpgrades if( !wrapper.enabled ) continue; ItemStack craftingStack = wrapper.upgrade.getCraftingItem(); - if( !craftingStack.isEmpty() && InventoryUtil.areItemsSimilar( stack, craftingStack ) ) + if( !craftingStack.isEmpty() && craftingStack.getItem() == stack.getItem() && wrapper.upgrade.isItemSuitable( stack ) ) { return wrapper.upgrade; } diff --git a/src/main/java/dan200/computercraft/shared/integration/jei/RecipeResolver.java b/src/main/java/dan200/computercraft/shared/integration/jei/RecipeResolver.java index 31cae9c9c..fa420f3ea 100644 --- a/src/main/java/dan200/computercraft/shared/integration/jei/RecipeResolver.java +++ b/src/main/java/dan200/computercraft/shared/integration/jei/RecipeResolver.java @@ -6,6 +6,7 @@ package dan200.computercraft.shared.integration.jei; import dan200.computercraft.ComputerCraft; +import dan200.computercraft.api.IUpgradeBase; import dan200.computercraft.api.pocket.IPocketUpgrade; import dan200.computercraft.api.turtle.ITurtleUpgrade; import dan200.computercraft.api.turtle.TurtleSide; @@ -16,7 +17,6 @@ import dan200.computercraft.shared.pocket.items.ItemPocketComputer; import dan200.computercraft.shared.pocket.items.PocketComputerItemFactory; import dan200.computercraft.shared.turtle.items.ITurtleItem; import dan200.computercraft.shared.turtle.items.TurtleItemFactory; -import dan200.computercraft.shared.util.InventoryUtil; import mezz.jei.api.constants.VanillaRecipeCategoryUid; import mezz.jei.api.recipe.IFocus; import mezz.jei.api.recipe.advanced.IRecipeManagerPlugin; @@ -83,7 +83,10 @@ class RecipeResolver implements IRecipeManagerPlugin for( UpgradeInfo upgrade : upgrades ) { ItemStack craftingStack = upgrade.stack; - if( !craftingStack.isEmpty() && InventoryUtil.areItemsSimilar( stack, craftingStack ) ) return true; + if( !craftingStack.isEmpty() && craftingStack.getItem() == stack.getItem() && upgrade.upgrade.isItemSuitable( stack ) ) + { + return true; + } } return false; @@ -194,11 +197,10 @@ class RecipeResolver implements IRecipeManagerPlugin List recipes = null; boolean multiple = false; - Ingredient ingredient = fromStacks( stack ); for( UpgradeInfo upgrade : upgrades ) { ItemStack craftingStack = upgrade.stack; - if( craftingStack.isEmpty() || !InventoryUtil.areItemsSimilar( stack, craftingStack ) ) + if( !craftingStack.isEmpty() && craftingStack.getItem() == stack.getItem() && upgrade.upgrade.isItemSuitable( stack ) ) { continue; } @@ -332,42 +334,29 @@ class RecipeResolver implements IRecipeManagerPlugin } } - private static final class Upgrade - { - final T upgrade; - final ItemStack stack; - final Ingredient ingredient; - - private Upgrade( T upgrade, ItemStack stack ) - { - this.upgrade = upgrade; - this.stack = stack; - ingredient = fromStacks( stack ); - } - } - private static class UpgradeInfo { final ItemStack stack; final Ingredient ingredient; final ITurtleUpgrade turtle; final IPocketUpgrade pocket; + final IUpgradeBase upgrade; ArrayList recipes; UpgradeInfo( ItemStack stack, ITurtleUpgrade turtle ) { this.stack = stack; - ingredient = fromStacks( stack ); - this.turtle = turtle; - pocket = null; + this.ingredient = fromStacks( stack ); + this.upgrade = this.turtle = turtle; + this.pocket = null; } UpgradeInfo( ItemStack stack, IPocketUpgrade pocket ) { this.stack = stack; - ingredient = fromStacks( stack ); - turtle = null; - this.pocket = pocket; + this.ingredient = fromStacks( stack ); + this.turtle = null; + this.upgrade = this.pocket = pocket; } List getRecipes() diff --git a/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleTool.java b/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleTool.java index f76e7b377..04505670e 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleTool.java +++ b/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleTool.java @@ -28,6 +28,7 @@ import net.minecraft.entity.item.ArmorStandEntity; import net.minecraft.fluid.IFluidState; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.DamageSource; import net.minecraft.util.Direction; @@ -38,6 +39,7 @@ import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.util.Constants; import net.minecraftforge.event.entity.player.AttackEntityEvent; import net.minecraftforge.event.world.BlockEvent; import org.apache.commons.lang3.tuple.Pair; @@ -68,6 +70,24 @@ public class TurtleTool extends AbstractTurtleUpgrade this.item = toolItem; } + @Override + public boolean isItemSuitable( @Nonnull ItemStack stack ) + { + CompoundNBT tag = stack.getTag(); + if( tag == null || tag.isEmpty() ) return true; + + // Check we've not got anything vaguely interesting on the item. We allow other mods to add their + // own NBT, with the understanding such details will be lost to the mist of time. + if( stack.isDamaged() || stack.isEnchanted() || stack.hasDisplayName() ) return false; + if( tag.contains( "AttributeModifiers", Constants.NBT.TAG_LIST ) && + !tag.getList( "AttributeModifiers", Constants.NBT.TAG_COMPOUND ).isEmpty() ) + { + return false; + } + + return true; + } + @Nonnull @Override @OnlyIn( Dist.CLIENT ) diff --git a/src/main/java/dan200/computercraft/shared/util/InventoryUtil.java b/src/main/java/dan200/computercraft/shared/util/InventoryUtil.java index 11b8438ec..8f8cff926 100644 --- a/src/main/java/dan200/computercraft/shared/util/InventoryUtil.java +++ b/src/main/java/dan200/computercraft/shared/util/InventoryUtil.java @@ -9,7 +9,6 @@ import net.minecraft.entity.Entity; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; @@ -40,35 +39,6 @@ public final class InventoryUtil return a == b || ItemHandlerHelper.canItemStacksStack( a, b ); } - /** - * Determines if two items are "mostly" equivalent. Namely, they have the same item and damage, and identical - * share stacks. - * - * This is largely based on {@link net.minecraftforge.common.crafting.IngredientNBT#test(ItemStack)}. It is - * sufficient to ensure basic information (such as enchantments) are the same, while not having to worry about - * capabilities. - * - * @param a The first stack to check - * @param b The second stack to check - * @return If these items are largely the same. - */ - public static boolean areItemsSimilar( @Nonnull ItemStack a, @Nonnull ItemStack b ) - { - if( a == b ) return true; - if( a.isEmpty() ) return !b.isEmpty(); - - if( a.getItem() != b.getItem() ) return false; - - // A more expanded form of ItemStack.areShareTagsEqual, but allowing an empty tag to be equal to a - // null one. - CompoundNBT shareTagA = a.getItem().getShareTag( a ); - CompoundNBT shareTagB = b.getItem().getShareTag( b ); - if( shareTagA == shareTagB ) return true; - if( shareTagA == null ) return shareTagB.isEmpty(); - if( shareTagB == null ) return shareTagA.isEmpty(); - return shareTagA.equals( shareTagB ); - } - // Methods for finding inventories: public static IItemHandler getInventory( World world, BlockPos pos, Direction side ) From 24bb92007ac83d22b61559d7d499364fa7c54f53 Mon Sep 17 00:00:00 2001 From: Jonathan Coates Date: Wed, 23 Dec 2020 15:58:40 +0000 Subject: [PATCH 35/38] Fix licence issues I knew I shouldn't do modding on things which aren't my main computer. I actually did run checkstyleMain before committing, but entirely forgot about this one. Go me. --- src/main/java/dan200/computercraft/api/IUpgradeBase.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/dan200/computercraft/api/IUpgradeBase.java b/src/main/java/dan200/computercraft/api/IUpgradeBase.java index 03a90571e..d3b4a0af1 100644 --- a/src/main/java/dan200/computercraft/api/IUpgradeBase.java +++ b/src/main/java/dan200/computercraft/api/IUpgradeBase.java @@ -1,3 +1,8 @@ +/* + * This file is part of the public ComputerCraft API - http://www.computercraft.info + * Copyright Daniel Ratcliffe, 2011-2020. This API may be redistributed unmodified and in full only. + * For help using the API, and posting your mods, visit the forums at computercraft.info. + */ package dan200.computercraft.api; import dan200.computercraft.api.pocket.IPocketUpgrade; From 16d74dd2e8709b4df35a826ca053b4a3c332f393 Mon Sep 17 00:00:00 2001 From: Lupus590 Date: Wed, 23 Dec 2020 16:19:54 +0000 Subject: [PATCH 36/38] Add functions to wrap text --- .../lua/rom/modules/main/cc/strings.lua | 102 ++++++++++++++++++ .../test-rom/spec/modules/cc/strings_spec.lua | 41 +++++++ 2 files changed, 143 insertions(+) create mode 100644 src/main/resources/data/computercraft/lua/rom/modules/main/cc/strings.lua create mode 100644 src/test/resources/test-rom/spec/modules/cc/strings_spec.lua diff --git a/src/main/resources/data/computercraft/lua/rom/modules/main/cc/strings.lua b/src/main/resources/data/computercraft/lua/rom/modules/main/cc/strings.lua new file mode 100644 index 000000000..1e6e6efc8 --- /dev/null +++ b/src/main/resources/data/computercraft/lua/rom/modules/main/cc/strings.lua @@ -0,0 +1,102 @@ +--- Various utilities for working with strings and text. +-- +-- @see textutils For additional string related utilities. + +local expect = require "cc.expect".expect + +--- Wraps a block of text, so that each line fits within the given width. +-- +-- This may be useful if you want to wrap text before displaying it to a +-- @{monitor} or @{printer} without using @{_G.print|print}. +-- +-- @tparam string text The string to wrap. +-- @tparam[opt] number width The width to constrain to, defaults to the width of +-- the terminal. +-- +-- @treturn { string... } The wrapped input string. +-- @usage require "cc.strings".wrap("This is a long piece of text", 10) +local function wrap(text, width) + expect(1, text, "string") + expect(2, width, "number", "nil") + width = width or term.getSize() + + + local lines, lines_n, current_line = {}, 0, "" + local function push_line() + lines_n = lines_n + 1 + lines[lines_n] = current_line + current_line = "" + end + + local pos, length = 1, #text + local sub, match = string.sub, string.match + while pos <= length do + local head = sub(text, pos, pos) + if head == " " or head == "\t" then + local whitespace = match(text, "^[ \t]+", pos) + current_line = current_line .. whitespace + pos = pos + #whitespace + elseif head == "\n" then + push_line() + pos = pos + 1 + else + local word = match(text, "^[^ \t\n]+", pos) + pos = pos + #word + if #word > width then + -- Print a multiline word + while #word > 0 do + local space_remaining = width - #current_line - 1 + if space_remaining <= 0 then + push_line() + space_remaining = width + end + + current_line = current_line .. sub(word, 1, space_remaining) + word = sub(word, space_remaining + 1) + end + else + -- Print a word normally + if width - #current_line < #word then push_line() end + current_line = current_line .. word + end + end + end + + push_line() + + -- Trim whitespace longer than width. + for k, line in pairs(lines) do + line = line:sub(1, width) + lines[k] = line + end + + return lines +end + +--- Makes the input string a fixed width. This either truncates it, or pads it +-- with spaces. +-- +-- @tparam string line The string to normalise. +-- @tparam[opt] number width The width to constrain to, defaults to the width of +-- the terminal. +-- +-- @treturn string The string with a specific width. +-- @usage require "cc.strings".ensure_width("a short string", 20) +-- @usage require "cc.strings".ensure_width("a rather long string which is truncated", 20) +local function ensure_width(line, width) + expect(1, line, "string") + expect(2, width, "number", "nil") + width = width or term.getSize() + + line = line:sub(1, width) + if #line < width then + line = line .. (" "):rep(width - #line) + end + + return line +end + +return { + wrap = wrap, + ensure_width = ensure_width, +} diff --git a/src/test/resources/test-rom/spec/modules/cc/strings_spec.lua b/src/test/resources/test-rom/spec/modules/cc/strings_spec.lua new file mode 100644 index 000000000..900c6fe6f --- /dev/null +++ b/src/test/resources/test-rom/spec/modules/cc/strings_spec.lua @@ -0,0 +1,41 @@ +describe("cc.pretty", function() + local str = require("cc.strings") + + describe("wrap", function() + it("validates arguments", function() + str.wrap("test string is long") + str.wrap("test string is long", 11) + expect.error(str.wrap, nil):eq("bad argument #1 (expected string, got nil)") + expect.error(str.wrap, "", false):eq("bad argument #2 (expected number, got boolean)") + end) + + it("wraps lines", function() + expect(str.wrap("test string is long")[1]):eq("test string is long") + + expect(str.wrap("test string is long", 15)[1]):eq("test string is ") + expect(str.wrap("test string is long", 15)[2]):eq("long") + + expect(str.wrap("test string is long", 12)[1]):eq("test string ") + expect(str.wrap("test string is long", 12)[2]):eq("is long") + + expect(str.wrap("test string is long", 11)[1]):eq("test string") + expect(str.wrap("test string is long", 11)[2]):eq("is long") + end) + end) + + describe("ensure_width", function() + it("validates arguments", function() + str.wrap("test string is long") + str.wrap("test string is long", 11) + expect.error(str.ensure_width, nil):eq("bad argument #1 (expected string, got nil)") + expect.error(str.ensure_width, "", false):eq("bad argument #2 (expected number, got boolean)") + end) + + it("pads lines", function() + expect(str.ensure_width("test string is long", 25)):eq("test string is long ") + end) + it("truncates lines", function() + expect(str.ensure_width("test string is long", 15)):eq("test string is ") + end) + end) +end) From ed3913c1f4959da9df31408af92182603672ad77 Mon Sep 17 00:00:00 2001 From: Jonathan Coates Date: Wed, 23 Dec 2020 16:33:58 +0000 Subject: [PATCH 37/38] Manually wrap strings for help (#602) This saves us writing to a buffer multiple times, and so makes things much, much faster. --- .../computercraft/lua/rom/programs/help.lua | 44 +++++++++---------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/src/main/resources/data/computercraft/lua/rom/programs/help.lua b/src/main/resources/data/computercraft/lua/rom/programs/help.lua index 149e9f41e..497a6dff7 100644 --- a/src/main/resources/data/computercraft/lua/rom/programs/help.lua +++ b/src/main/resources/data/computercraft/lua/rom/programs/help.lua @@ -13,6 +13,19 @@ if sTopic == "index" then return end +local strings = require "cc.strings" +local function word_wrap(text, width) + local lines = strings.wrap(text, width) + + -- Normalise the strings suitable for use with blit. We could skip this and + -- just use term.write, but saves us a clearLine call. + for k, line in pairs(lines) do + lines[k] = strings.ensure_width(line, width) + end + + return lines +end + local sFile = help.lookup(sTopic) local file = sFile ~= nil and io.open(sFile) or nil if not file then @@ -24,37 +37,27 @@ local contents = file:read("*a"):gsub("(\n *)[-*]( +)", "%1\7%2") file:close() local width, height = term.getSize() -local buffer = window.create(term.current(), 1, 1, width, height, false) -local old_term = term.redirect(buffer) - -local print_height = print(contents) + 1 +local lines = word_wrap(contents, width) +local print_height = #lines -- If we fit within the screen, just display without pagination. if print_height <= height then - term.redirect(old_term) print(contents) return end -local function draw_buffer(width) - buffer.reposition(1, 1, width, print_height) - buffer.clear() - buffer.setCursorPos(1, 1) - print(contents) - term.redirect(old_term) -end - local offset = 0 local function draw() + local fg, bg = ("0"):rep(width), ("f"):rep(width) for y = 1, height - 1 do term.setCursorPos(1, y) if y + offset > print_height then - -- Should only happen if we resize the terminal to a larger one - -- than actually needed for the current text. + -- Should only happen if we resize the terminal to a larger one + -- than actually needed for the current text. term.clearLine() else - term.blit(buffer.getLine(y + offset)) + term.blit(lines[y + offset], fg, bg) end end end @@ -73,7 +76,6 @@ local function draw_menu() end end -draw_buffer(width) draw() draw_menu() @@ -114,11 +116,8 @@ while true do local new_width, new_height = term.getSize() if new_width ~= width then - buffer.setCursorPos(1, 1) - buffer.reposition(1, 1, new_width, print_height) - term.redirect(buffer) - print_height = print(contents) + 1 - draw_buffer(new_width) + lines = word_wrap(contents, new_width) + print_height = #lines end width, height = new_width, new_height @@ -128,6 +127,5 @@ while true do end end -term.redirect(old_term) term.setCursorPos(1, 1) term.clear() From 7f9a707f75636d5816f752dc93d7b6b998c61a03 Mon Sep 17 00:00:00 2001 From: Jonathan Coates Date: Fri, 25 Dec 2020 16:40:50 +0000 Subject: [PATCH 38/38] Bump version to 1.95.0 As is tradition. --- gradle.properties | 2 +- .../computercraft/lua/rom/help/changelog.txt | 22 ++++++++++++++++ .../computercraft/lua/rom/help/whatsnew.txt | 26 +++++++++++++------ 3 files changed, 41 insertions(+), 9 deletions(-) diff --git a/gradle.properties b/gradle.properties index 5c6f6ea2b..147cc11de 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ # Mod properties -mod_version=1.94.0 +mod_version=1.95.0 # Minecraft properties (update mods.toml when changing) mc_version=1.15.2 diff --git a/src/main/resources/data/computercraft/lua/rom/help/changelog.txt b/src/main/resources/data/computercraft/lua/rom/help/changelog.txt index b173cbceb..52789f9d8 100644 --- a/src/main/resources/data/computercraft/lua/rom/help/changelog.txt +++ b/src/main/resources/data/computercraft/lua/rom/help/changelog.txt @@ -1,3 +1,25 @@ +# New features in CC: Tweaked 1.95.0 + +* Optimise the paint program's initial render. +* Several documentation improvments (Gibbo3771, MCJack123). +* `fs.combine` now accepts multiple arguments. +* Add a setting (`bios.strict_globals`) to error when accidentally declaring a global. (Lupus590). +* Add an improved help viewer which allows scrolling up and down (MCJack123). +* Add `cc.strings` module, with utilities for wrapping text (Lupus590). +* The `clear` program now allows resetting the palette too (Luca0208). + +And several bug fixes: +* Fix memory leak in generic peripherals. +* Fix crash when a turtle is broken while being ticked. +* `textutils.*tabulate` now accepts strings _or_ numbers. +* We now deny _all_ local IPs, using the magic `$private` host. Previously the IPv6 loopback interface was not blocked. +* Fix crash when rendering monitors if the block has not yet been synced. You will need to regenerate the config file to apply this change. +* `read` now supports numpad enter (TheWireLord) +* Correctly handle HTTP redirects to URLs containing escape characters. +* Fix integer overflow in `os.epoch`. +* Allow using pickaxes (and other items) for turtle upgrades which have mod-specific NBT. +* Fix duplicate turtle/pocket upgrade recipes appearing in JEI. + # New features in CC: Tweaked 1.94.0 * Add getter for window visibility (devomaa) diff --git a/src/main/resources/data/computercraft/lua/rom/help/whatsnew.txt b/src/main/resources/data/computercraft/lua/rom/help/whatsnew.txt index 563dc0f69..477a8bbe1 100644 --- a/src/main/resources/data/computercraft/lua/rom/help/whatsnew.txt +++ b/src/main/resources/data/computercraft/lua/rom/help/whatsnew.txt @@ -1,13 +1,23 @@ -New features in CC: Tweaked 1.94.0 +New features in CC: Tweaked 1.95.0 -* Add getter for window visibility (devomaa) -* Generic peripherals are no longer experimental, and on by default. -* Use term.blit to draw boxes in paintutils (Lemmmy). +* Optimise the paint program's initial render. +* Several documentation improvments (Gibbo3771, MCJack123). +* `fs.combine` now accepts multiple arguments. +* Add a setting (`bios.strict_globals`) to error when accidentally declaring a global. (Lupus590). +* Add an improved help viewer which allows scrolling up and down (MCJack123). +* Add `cc.strings` module, with utilities for wrapping text (Lupus590). +* The `clear` program now allows resetting the palette too (Luca0208). And several bug fixes: -* Fix turtles not getting advancements when turtles are on. -* Draw in-hand pocket computers with the correct transparent flags enabled. -* Several bug fixes to SNBT parsing. -* Fix several programs using their original name instead of aliases in usage hints (Lupus590). +* Fix memory leak in generic peripherals. +* Fix crash when a turtle is broken while being ticked. +* `textutils.*tabulate` now accepts strings _or_ numbers. +* We now deny _all_ local IPs, using the magic `$private` host. Previously the IPv6 loopback interface was not blocked. +* Fix crash when rendering monitors if the block has not yet been synced. You will need to regenerate the config file to apply this change. +* `read` now supports numpad enter (TheWireLord) +* Correctly handle HTTP redirects to URLs containing escape characters. +* Fix integer overflow in `os.epoch`. +* Allow using pickaxes (and other items) for turtle upgrades which have mod-specific NBT. +* Fix duplicate turtle/pocket upgrade recipes appearing in JEI. Type "help changelog" to see the full version history.