From 973da5d4b31283862e7ea7e353c4368d1a1b393f Mon Sep 17 00:00:00 2001 From: stfwi Date: Tue, 2 Jul 2019 20:45:03 +0200 Subject: [PATCH] Build/porting tools updated. Updater info updated. --- 1.14/Makefile | 7 +++- 1.14/meta/lib/halfslab_assets.js | 61 ++++++++++++++++++++++++++++++ 1.14/meta/lib/slab_assets.js | 64 ++++++++++++++++++++++++++++++++ 1.14/meta/update.json | 3 +- 1.14/readme.md | 3 +- 1.14/tasks.js | 32 ++++++++++++++++ meta/lib/constants.js | 3 +- meta/update.json | 3 +- 8 files changed, 171 insertions(+), 5 deletions(-) create mode 100644 1.14/meta/lib/halfslab_assets.js create mode 100644 1.14/meta/lib/slab_assets.js diff --git a/1.14/Makefile b/1.14/Makefile index bc23ff6..f472b17 100644 --- a/1.14/Makefile +++ b/1.14/Makefile @@ -24,7 +24,7 @@ wildcardr=$(foreach d,$(wildcard $1*),$(call wildcardr,$d/,$2) $(filter $(subst # # Targets # -.PHONY: default mod init clean clean-all mrproper all run install sanatize dist-check dist start-server +.PHONY: default mod init clean clean-all mrproper all run install sanatize dist-check dist start-server assets default: mod @@ -76,3 +76,8 @@ dist: sanatize dist-check clean-all mod @mkdir -p dist @cp build/libs/$(MOD_JAR_PREFIX)* dist/ @djs tasks.js dist + +assets: + @echo "[1.14] Running asset generators ..." + @djs tasks.js create-slab-assets + @djs tasks.js create-half-slab-assets \ No newline at end of file diff --git a/1.14/meta/lib/halfslab_assets.js b/1.14/meta/lib/halfslab_assets.js new file mode 100644 index 0000000..be82d07 --- /dev/null +++ b/1.14/meta/lib/halfslab_assets.js @@ -0,0 +1,61 @@ +#!/usr/bin/djs +// run from tasks.js directory +"use strict"; +(function(constants, libassets){ + const me = {}; + const modid = constants.mod_registry_name(); + const assets_root = constants.local_assets_root(); + const hexchar = ['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e']; // ('a'+parts) won't work so here we go + + const create_item_model = function(prefix, texture) { + const model = { + parent: modid+":block/slab/generic/halfslab_inventory_model", + textures: { all: texture } + } + const path = "models/item/halfslab_"+prefix+".json"; + if(!fs.writefile(path, JSON.stringify(model))) { + throw new Error("Failed to write item model file '"+ path +"'"); + } + }; + + const create_block_models = function(prefix, texture) { + for(var parts=0; parts<15; ++parts) { + const model = { + parent: modid+":block/slab/generic/halfslab_s"+hexchar[parts]+"_model", + textures: { all:texture } + } + const path = "models/block/slab/specific/halfslab_"+prefix+"_s"+hexchar[parts]+"_model.json"; + if(!fs.writefile(path, JSON.stringify(model))) { + throw new Error("Failed to write model file '"+ path +"'"); + } + } + }; + + const create_blockstate = function(prefix) { + var variants = {}; + for(var parts=0; parts<15; ++parts) { + variants[ ("parts="+parts).replace(/[\s]/g,"") ] = { + model: (modid+":block/slab/specific/halfslab_"+prefix+"_s"+hexchar[parts]+"_model").replace(/[\s]/g,"") + } + } + const path = "blockstates/halfslab_"+prefix+".json"; + if(!fs.writefile(path, JSON.stringify({variants:variants},null,1))) throw new Error("Failed to write blockstate '"+path+"'"); + return path; + }; + + me.create = function(data) { + const here = fs.cwd() + const registry_name_prefix = data.name_prefix; + const texture = data.texture; + if(!fs.chdir(assets_root)) throw new Error("Could not switch to assets root folder: '" + assets_root + "'"); + try { + create_block_models(registry_name_prefix, texture); + create_item_model(registry_name_prefix, texture); + create_blockstate(registry_name_prefix, texture); + } finally { + fs.chdir(here); + } + } + Object.freeze(me); + return me; +}); diff --git a/1.14/meta/lib/slab_assets.js b/1.14/meta/lib/slab_assets.js new file mode 100644 index 0000000..8ddf39c --- /dev/null +++ b/1.14/meta/lib/slab_assets.js @@ -0,0 +1,64 @@ +#!/usr/bin/djs +// run from tasks.js directory +"use strict"; +(function(constants, libassets){ + const me = {}; + const modid = constants.mod_registry_name(); + const assets_root = constants.local_assets_root(); + + const create_item_model = function(prefix, texture_prefix) { + const model = { + parent: modid+":block/slab/generic/slab_inventory_model", + textures: { all: modid+":block/"+texture_prefix+"0" } + } + const path = "models/item/"+prefix+"_slab.json"; + if(!fs.writefile(path, JSON.stringify(model))) { + throw new Error("Failed to write item model file '"+ path +"'"); + } + }; + + const create_block_models = function(prefix, texture_prefix) { + for(var parts=0; parts<3; ++parts) { + for(var tvariant=0; tvariant<4; ++tvariant) { + const model = { + parent: modid+":block/slab/generic/slab_s"+parts+"_model", + textures: { all: modid+":block/"+texture_prefix+tvariant } + } + const path = "models/block/slab/specific/"+prefix+"_slab_s"+parts+"v"+tvariant+"_model.json"; + if(!fs.writefile(path, JSON.stringify(model))) { + throw new Error("Failed to write model file '"+ path +"'"); + } + } + } + }; + + const create_blockstate = function(prefix) { + var variants = {}; + for(var parts=0; parts<3; ++parts) { + for(var tvariant=0; tvariant<4; ++tvariant) { + variants[ ("parts="+parts+",tvariant="+tvariant).replace(/[\s]/g,"") ] = { + model: (modid+":block/slab/specific/"+prefix+"_slab_s"+parts+"v"+tvariant+"_model").replace(/[\s]/g,"") + } + } + } + const path = "blockstates/"+prefix+"_slab.json"; + if(!fs.writefile(path, JSON.stringify({variants:variants},null,1))) throw new Error("Failed to write blockstate '"+path+"'"); + return path; + }; + + me.create = function(prefixes) { + const here = fs.cwd() + const registry_name_prefix = prefixes.name_prefix; + const texture_prefix = prefixes.texture_prefix; + if(!fs.chdir(assets_root)) throw new Error("Could not switch to assets root folder: '" + assets_root + "'"); + try { + create_block_models(registry_name_prefix, texture_prefix); + create_item_model(registry_name_prefix, texture_prefix); + create_blockstate(registry_name_prefix, texture_prefix); + } finally { + fs.chdir(here); + } + } + Object.freeze(me); + return me; +}); diff --git a/1.14/meta/update.json b/1.14/meta/update.json index 19d7904..2b33c94 100644 --- a/1.14/meta/update.json +++ b/1.14/meta/update.json @@ -1,6 +1,7 @@ { "homepage": "https://www.curseforge.com/minecraft/mc-mods/engineers-decor/", "1.14.2": { + "1.0.8-b3": "[A] Ported slabs and slab slices from 1.12.2.\n[A] IE independent (\"standalone\") recipes ported.", "1.0.8-b2": "[U] Updated to Forge BETA 1.14.2-26.0.63/20190621-1.14.2, code adapted to new mappings.\n[M] Updated 1st/3rd person item model rotations/translations.", "1.0.8-b1": "[V] Feature set of 1.12 ported.\n[A] CTRL-SHIFT tooltips ported.\n[A] Ported stained clinker block/stairs.\n[M] Updated textures.\n[I] Issue: Scoped recipe constants still not working.", "1.0.7-b5": "[U] Updated to Forge BETA 1.14.2-26.0.35/20190608-1.14.2.\n[A] Factory dropper functionality ported.\n[A] Small lab furnace functionality ported.\n[A] Small electrical lab furnace functionality ported.\n[A] Small waste incinerator functionality ported.\n[A] Fluid valves, Passive Fluid Accumulator ported.\n[I] Issue: Scoped recipe constants still not working.", @@ -9,6 +10,6 @@ }, "promos": { "1.14.2-recommended": "", - "1.14.2-latest": "1.0.8-b2" + "1.14.2-latest": "1.0.8-b3" } } \ No newline at end of file diff --git a/1.14/readme.md b/1.14/readme.md index 943c4e4..f66857c 100644 --- a/1.14/readme.md +++ b/1.14/readme.md @@ -10,7 +10,8 @@ Mod sources for Minecraft version 1.14.2. ---- ## Version history - ~ v1.0.8-b3 [U] + - v1.0.8-b3 [A] Ported slabs and slab slices from 1.12.2. + [A] IE independent ("standalone") recipes ported. - v1.0.8-b2 [U] Updated to Forge BETA 1.14.2-26.0.63/20190621-1.14.2, code adapted to new mappings. diff --git a/1.14/tasks.js b/1.14/tasks.js index 1238ee0..f0920ad 100644 --- a/1.14/tasks.js +++ b/1.14/tasks.js @@ -10,4 +10,36 @@ tasks["sync-languages"] = function() { liblang.sync_languages(); }; +tasks["create-slab-assets"] = function() { + const libassets = include("../meta/lib/libassets.js")(constants); + const slab_assets = include("meta/lib/slab_assets.js")(constants, libassets); + const block_prefixes = [ + { name_prefix:"clinker_brick", texture_prefix:"clinker_brick/clinker_brick_texture" }, + { name_prefix:"clinker_brick_stained", texture_prefix:"clinker_brick/clinker_brick_stained_texture" }, + { name_prefix:"panzerglass", texture_prefix:"glass/panzerglass_block_texture" }, + { name_prefix:"rebar_concrete", texture_prefix:"concrete/rebar_concrete_texture" }, + { name_prefix:"rebar_concrete_tile", texture_prefix:"concrete/rebar_concrete_tile_texture" }, + { name_prefix:"slag_brick", texture_prefix:"slag_brick/slag_brick_texture" }, + ]; + for(var i in block_prefixes) slab_assets.create(block_prefixes[i]); +} + +tasks["create-half-slab-assets"] = function() { + const libassets = include("../meta/lib/libassets.js")(constants); + const halfslab_assets = include("meta/lib/halfslab_assets.js")(constants, libassets); + const modid = constants.mod_registry_name(); + const block_data = [ + { name_prefix:"rebar_concrete", texture:modid+":block/concrete/rebar_concrete_texture0" }, + { name_prefix:"concrete", texture:modid+":block/ieoriginal/ie_stone_decoration_concrete" }, + { name_prefix:"treated_wood", texture:"immersiveengineering:blocks/treated_wood" }, + { name_prefix:"sheetmetal_iron", texture:"immersiveengineering:blocks/sheetmetal_iron" }, + { name_prefix:"sheetmetal_steel", texture:"immersiveengineering:blocks/sheetmetal_steel" }, + { name_prefix:"sheetmetal_copper", texture:"immersiveengineering:blocks/sheetmetal_copper" }, + { name_prefix:"sheetmetal_gold", texture:"immersiveengineering:blocks/sheetmetal_gold" }, + { name_prefix:"sheetmetal_aluminum", texture:"immersiveengineering:blocks/sheetmetal_aluminum" }, + // { name_prefix:"clinker_brick", texture:modid+":block/clinker_brick/clinker_brick_texture0" } + ]; + for(var i in block_data) halfslab_assets.create(block_data[i]); +} + libtask.run(tasks, sys.args); diff --git a/meta/lib/constants.js b/meta/lib/constants.js index dc5d30a..8ac4431 100644 --- a/meta/lib/constants.js +++ b/meta/lib/constants.js @@ -2,6 +2,7 @@ (function(){ var c = {}; c.mod_registry_name = function() { return "engineersdecor" } + c.local_assets_root = function() { return "src/main/resources/assets/" + c.mod_registry_name(); } c.reference_repository = function() { return "git@github.com:stfwi/engineers-decor.git"; } c.gradle_property_modversion = function() { return "version_engineersdecor"; } c.gradle_property_version_minecraft = function() { return "version_minecraft"; } @@ -16,4 +17,4 @@ Object.freeze(c.languages); Object.freeze(c); return c; -}); \ No newline at end of file +}); diff --git a/meta/update.json b/meta/update.json index 238d1d1..63529ae 100644 --- a/meta/update.json +++ b/meta/update.json @@ -60,6 +60,7 @@ "1.0.0-a1": "[A] Initial port to 1.13.2 with Forge beta." }, "1.14.2": { + "1.0.8-b3": "[A] Ported slabs and slab slices from 1.12.2.\n[A] IE independent (\"standalone\") recipes ported.", "1.0.8-b2": "[U] Updated to Forge BETA 1.14.2-26.0.63/20190621-1.14.2, code adapted to new mappings.\n[M] Updated 1st/3rd person item model rotations/translations.", "1.0.8-b1": "[V] Feature set of 1.12 ported.\n[A] CTRL-SHIFT tooltips ported.\n[A] Ported stained clinker block/stairs.\n[M] Updated textures.\n[I] Issue: Scoped recipe constants still not working.", "1.0.7-b5": "[U] Updated to Forge BETA 1.14.2-26.0.35/20190608-1.14.2.\n[A] Factory dropper functionality ported.\n[A] Small lab furnace functionality ported.\n[A] Small electrical lab furnace functionality ported.\n[A] Small waste incinerator functionality ported.\n[A] Fluid valves, Passive Fluid Accumulator ported.\n[I] Issue: Scoped recipe constants still not working.", @@ -72,6 +73,6 @@ "1.13.2-recommended": "", "1.13.2-latest": "1.0.7-b5", "1.14.2-recommended": "", - "1.14.2-latest": "1.0.8-b2" + "1.14.2-latest": "1.0.8-b3" } } \ No newline at end of file