From 7dd50818417c34c17475e960962817aa559fe419 Mon Sep 17 00:00:00 2001 From: Matthew Messinger Date: Mon, 5 Nov 2018 19:32:30 -0500 Subject: [PATCH] Fixup the buildscript for loading in background ponies. Removed the pack zipper. It's in a separate repo. Just download the zip from github. --- build.gradle | 66 +++++++++++++++++++++++++++------------------------- skins | 2 +- 2 files changed, 35 insertions(+), 33 deletions(-) diff --git a/build.gradle b/build.gradle index d1a5caf2..190191d1 100644 --- a/build.gradle +++ b/build.gradle @@ -111,31 +111,40 @@ jar { archivesBaseName = "mod-${project.name.toLowerCase()}" task copyBGPones(type: Copy) { - delete "${buildDir}/skins/assets/minelittlepony/textures/entity/pony" - - // use the same rejex for both filenames and the bgponies.json - // Otherwise there could be errors because of the names in the json not matching the ones on disk - def permittedChars = /[^0-9a-z_-\",\t\{\}\[\]\(\):\'\.\/ ]/ - - from("skins/Background Ponies") { - exclude "bgponies.json" - - rename { filename -> - filename.toLowerCase() - .replaceAll(permittedChars, '') + + def illegals = /[^a-z0-9_\/.-]/ + + from "skins/background_ponies" + into temporaryDir + + include '**/*.png' + + eachFile { + if (it.name =~ illegals){ + logger.warn("Sanitizing file with illegal characters: ${it.path}") + it.name = it.name.replaceAll(/\s/, '_').replaceAll(illegals, '') } } - - from("skins/Background Ponies") { - include "bgponies.json" - - filter { line -> - line.toLowerCase() - .replaceAll(permittedChars, '') - } +} + +import groovy.json.JsonBuilder + +task genPoniesJson(dependsOn: copyBGPones) { + // loop through the background ponies to create the bgponies.json + + def bgponies = 'bgponies.json' + + def json = file("$temporaryDir/$bgponies") + + inputs.dir copyBGPones.outputs + outputs.file json + + doFirst { + json.text = new JsonBuilder( + override: false, + ponies: fileTree(copyBGPones.outputs.files.singleFile).filter { it.file }.collect { it.name.replace(".png", "") } + ).toPrettyString() } - - into "${buildDir}/skins/assets/minelittlepony/textures/entity/pony" } shadowJar { @@ -149,6 +158,9 @@ shadowJar { from(copyBGPones) { into "/assets/minelittlepony/textures/entity/pony" } + from (genPoniesJson){ + into "/assets/minelittlepony/textures/entity/pony" + } dependencies { exclude dependency('deobf.com.mumfrey:liteloader:') @@ -174,16 +186,6 @@ task srgJar(type: Jar) { classifier "mc$minecraft.version-srg" } -task zipCommunityPack(type: Zip) { - baseName = "Pony Skin Pack" - destinationDir = new File(buildDir, "libs") - from("skins") { - // TODO: Later packs will have their folders excluded. - // For now we just zip everything. - exclude "README.md" - } -} - reobf { srgJar { mappingType = 'SEARGE' diff --git a/skins b/skins index 3f99def1..e5250bdc 160000 --- a/skins +++ b/skins @@ -1 +1 @@ -Subproject commit 3f99def1cd53359a11ffb5dc7b0069402a3bc0e3 +Subproject commit e5250bdc971f7256d77ca9be1570e0899d3a5dc3