Skip to content

Commit a4ebc9a

Browse files
authored
Merge pull request #535 from SkyBlade1978/feature/1.12-ore-overlays
Use ore overlays on Minecraft 1.12.2
2 parents d231521 + a6e2890 commit a4ebc9a

40 files changed

Lines changed: 206 additions & 94 deletions

‎.github/workflows/ci.yml‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ jobs:
157157
cp build/release/SHA256SUMS "$RUNNER_TEMP/first-SHA256SUMS"
158158
159159
- name: Verify reproducible release archives
160+
id: release_archives
160161
shell: bash
161162
run: |
162163
set -euo pipefail
@@ -170,6 +171,9 @@ jobs:
170171
)
171172
./gradlew "${gradle_args[@]}"
172173
cmp "$RUNNER_TEMP/first-SHA256SUMS" build/release/SHA256SUMS
174+
version="$(sed -n 's/^mod_version=//p' gradle.properties)"
175+
[[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]
176+
echo "version=$version" >> "$GITHUB_OUTPUT"
173177
174178
- name: Upload audited release candidate
175179
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
@@ -178,9 +182,9 @@ jobs:
178182
if-no-files-found: error
179183
retention-days: 30
180184
path: |
181-
build/libs/BaseMetals-2.6.2.112021.jar
182-
build/libs/BaseMetals-2.6.2.112021-sources.jar
183-
build/libs/BaseMetals-2.6.2.112021-javadoc.jar
185+
build/libs/BaseMetals-${{ steps.release_archives.outputs.version }}.jar
186+
build/libs/BaseMetals-${{ steps.release_archives.outputs.version }}-sources.jar
187+
build/libs/BaseMetals-${{ steps.release_archives.outputs.version }}-javadoc.jar
184188
build/release/SHA256SUMS
185189
CHANGELOG.txt
186190

‎CHANGELOG.txt‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
Base Metals 2.6.3.112021 — Minecraft 1.12.2
2+
3+
- Brought KiriCattus's ore overlays to Minecraft 1.12.2. If your resource
4+
pack changes stone, netherrack or end stone, Base Metals ores now match
5+
the surrounding rock and keep their ore markings.
6+
- Ore placement and existing worlds are unchanged.
7+
18
Base Metals 2.6.2.112021 — Minecraft 1.12.2
29

310
- Updated to OreSpawn 4.1.6.112021. Install it on both the client and server.

‎README.md‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@ Base Metals adds metals, alloys, equipment, building blocks, and the crackhammer
1010
Crush ores into powder, smelt the powder into ingots, or combine it into alloy
1111
blends. The metals also work with supported processing and tool-building mods.
1212

13-
This branch builds **2.6.2.112021** for Minecraft 1.12.2 and Forge. I've
14-
updated OreSpawn support so saved ore settings carry over when you move an
15-
older world. This update also fixes shallow molten metal not burning on
16-
contact and gives players a clear message if their Fantasy Level doesn't
17-
match the server's. See the [changelog](CHANGELOG.txt) for the details.
13+
Version **2.6.3.112021** brings the ore overlays from newer versions of
14+
Base Metals to Minecraft 1.12.2. Ores now match your resource pack's rock
15+
textures. You can update an existing world without changing where ores spawn.
16+
See the [changelog](CHANGELOG.txt) for what's changed.
1817

1918
## Installation
2019

@@ -61,6 +60,11 @@ End. Copper, Silver, Tin, Lead, Zinc, Mercury, Nickel, and Platinum generate
6160
in ordinary dimensions. Antimony and Bismuth ore blocks are available, but
6261
they do not generate by default. Aquarium and Mithril are alloys, not ores.
6362

63+
Base Metals ores use your resource pack's stone, netherrack and end stone.
64+
The ore markings are a separate layer, using textures by KiriCattus. Pack
65+
makers can replace those markings in
66+
`assets/basemetals/textures/blocks/ore_overlays/`.
67+
6468
Make alloys by combining powders in a crafting grid and smelting the resulting
6569
blend. For example, Bronze uses Copper and Tin; Steel uses Iron and carbon.
6670
Vanilla Bits adds useful forms for vanilla materials, such as Iron powder,
@@ -144,11 +148,13 @@ toolchain and dependency versions are recorded in `gradle.properties`.
144148

145149
`prepareEclipse` creates client and server launches with processed resources
146150
and keeps optional compile-only mods and test code out of normal launches.
151+
After updating an existing Eclipse project, use **Gradle → Refresh Gradle
152+
Project** so Eclipse picks up the generated ore models.
147153
The [build-script guide](gradle/README.md) explains the supporting scripts.
148154
The [release guide](docs/releasing.md) covers publication from the MMD Actions tab.
149155

150156
Release artifacts use the Maven coordinates
151-
`zone.moddev.mc.basemetals:BaseMetals:2.6.2.112021`. Java packages remain under
157+
`zone.moddev.mc.basemetals:BaseMetals:2.6.3.112021`. Java packages remain under
152158
`com.mcmoddev.basemetals`; this release does not move saved registry names.
153159

154160
Report bugs through the [issue tracker](https://github.com/MinecraftModDevelopmentMods/BaseMetals/issues).

‎build.gradle‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ repositories {
195195
}
196196

197197
apply from: 'gradle/dependencies.gradle'
198+
apply from: 'gradle/ore-models.gradle'
198199
apply from: 'gradle/data/recipe-advancements.gradle'
199200
apply from: 'gradle/data/gameplay-advancements.gradle'
200201

‎gradle.properties‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ org.gradle.parallel=false
66
net.minecraftforge.gradle.merge-source-sets=false
77

88
mod_group=zone.moddev.mc.basemetals
9-
mod_version=2.6.2.112021
9+
mod_version=2.6.3.112021
1010

1111
# Generic release-dispatcher metadata.
1212
minecraft_version=1.12.2

‎gradle/ide/eclipse.gradle‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import groovy.xml.XmlSlurper
2+
13
// Eclipse support repairs ForgeGradle's generated launches without changing product dependencies.
24
idea {
35
module {
@@ -184,6 +186,14 @@ tasks.register('verifyEclipseProductionClasspath') {
184186
|| eclipseClasspath ==~ /(?s).*<classpathentry[^>]+path="[A-Za-z]:[\\\/].*/) {
185187
throw new GradleException('Eclipse must expose dependencies through the Buildship container only')
186188
}
189+
File generatedOreModels = tasks.named('generateOreModels').get().outputs.files.singleFile
190+
String oreModelSource = project.relativePath(generatedOreModels).replace('\\', '/')
191+
def classpathEntries = new XmlSlurper().parseText(eclipseClasspath).classpathentry
192+
if (!classpathEntries.any { entry ->
193+
entry.@kind.text() == 'src' && entry.@path.text() == oreModelSource && entry.@output.text() == 'bin/main'
194+
}) {
195+
throw new GradleException("Eclipse must copy the generated ore models from ${oreModelSource} into bin/main")
196+
}
187197
List<File> runtimeArchives = configurations.runtimeClasspath.files.collect {
188198
it.canonicalFile
189199
}

‎gradle/ore-models.gradle‎

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
import groovy.json.JsonOutput
2+
import groovy.json.JsonSlurper
3+
4+
import javax.imageio.ImageIO
5+
6+
// KiriCattus's two-layer model uses the legacy texture paths on these Forge versions.
7+
def hosts = [
8+
adamantine_ore: 'netherrack', antimony_ore: 'stone', bismuth_ore: 'stone',
9+
coldiron_ore: 'netherrack', copper_ore: 'stone', lead_ore: 'stone',
10+
mercury_ore: 'stone', nickel_ore: 'stone', platinum_ore: 'stone',
11+
silver_ore: 'stone', starsteel_ore: 'end_stone', tin_ore: 'stone', zinc_ore: 'stone'
12+
].asImmutable()
13+
ext.baseMetalsOreOverlayIds = hosts.keySet().toList().asImmutable()
14+
15+
def assets = layout.projectDirectory.dir('src/main/resources/assets/basemetals')
16+
def textures = assets.dir('textures/blocks/ore_overlays')
17+
def overlayFiles = fileTree(textures) { include '*_ore.png' }
18+
def oreStates = fileTree(assets.dir('blockstates')) { include '*_ore.json' }
19+
def oreItems = fileTree(assets.dir('models/item')) { include '*_ore.json' }
20+
def generated = layout.buildDirectory.dir('generated/ore-models')
21+
def sides = ['down', 'up', 'north', 'south', 'west', 'east']
22+
23+
def cube = { Number from, Number to, String texture ->
24+
def faces = sides.collectEntries { side ->
25+
[(side): [texture: texture, cullface: side, uv: [0, 0, 16, 16]]]
26+
}
27+
[from: [from, from, from], to: [to, to, to], faces: faces]
28+
}
29+
30+
def models = [ore_overlay: [
31+
parent: 'minecraft:block/block',
32+
elements: [cube(0, 16, '#base'), cube(-0.05, 16.05, '#overlay')]
33+
]]
34+
hosts.each { id, host ->
35+
def base = "minecraft:blocks/${host}".toString()
36+
models[id] = [
37+
parent: 'basemetals:block/ore_overlay',
38+
textures: [particle: base, base: base, overlay: "basemetals:blocks/ore_overlays/${id}".toString()]
39+
]
40+
}
41+
42+
def generateOreModels = tasks.register('generateOreModels') {
43+
group = 'build'
44+
description = 'Generates the ore models from KiriCattus’s textures and vanilla rock.'
45+
inputs.files(overlayFiles, oreStates, oreItems).withPathSensitivity(PathSensitivity.RELATIVE)
46+
inputs.property('models', JsonOutput.toJson(models))
47+
outputs.dir(generated)
48+
49+
doLast {
50+
def found = overlayFiles.files.collect { it.name - '.png' }.toSet()
51+
if (found != hosts.keySet()) {
52+
throw new GradleException("Ore textures do not match the model list: missing ${hosts.keySet() - found}, extra ${found - hosts.keySet()}")
53+
}
54+
55+
def json = new JsonSlurper()
56+
hosts.keySet().each { id ->
57+
def state = json.parse(assets.file("blockstates/${id}.json").asFile)
58+
def item = json.parse(assets.file("models/item/${id}.json").asFile)
59+
if (state.variants?.normal?.model != "basemetals:${id}" || item.parent != "basemetals:block/${id}") {
60+
throw new GradleException("The block and item must both use the generated model for ${id}")
61+
}
62+
63+
def image = ImageIO.read(textures.file("${id}.png").asFile)
64+
if (image == null) throw new GradleException("Cannot read the overlay for ${id}")
65+
def alpha = image.getRGB(0, 0, image.width, image.height, null, 0, image.width).collect { it >>> 24 }
66+
if (!alpha.contains(0) || !alpha.any { it >= 128 }) {
67+
throw new GradleException("The overlay for ${id} must show both the ore and the rock behind it")
68+
}
69+
}
70+
71+
def dir = generated.get().dir('assets/basemetals/models/block').asFile
72+
dir.mkdirs()
73+
models.each { id, model ->
74+
new File(dir, "${id}.json").setText(JsonOutput.prettyPrint(JsonOutput.toJson(model)) + '\n', 'UTF-8')
75+
}
76+
dir.listFiles().findAll { it.isFile() && it.name.endsWith('.json') && !models.containsKey(it.name - '.json') }.each {
77+
if (!it.delete()) throw new GradleException("Could not remove stale generated model ${it.name}")
78+
}
79+
}
80+
}
81+
82+
// Eclipse copies these models into bin/main just like the other game resources.
83+
sourceSets.main.resources.srcDir(generateOreModels)
84+
85+
['genEclipseRuns', 'eclipseClasspath'].each { taskName ->
86+
tasks.named(taskName) { dependsOn generateOreModels }
87+
}
88+
89+
def processResources = tasks.named('processResources', ProcessResources)
90+
91+
def verifyOreOverlayModels = tasks.register('verifyOreOverlayModels') {
92+
group = 'verification'
93+
description = 'Checks that the processed block and item resources use the generated ore overlays.'
94+
dependsOn processResources
95+
96+
doLast {
97+
def root = new File(processResources.get().destinationDir, 'assets/basemetals')
98+
def json = new JsonSlurper()
99+
models.each { id, expected ->
100+
def path = new File(root, "models/block/${id}.json")
101+
if (!path.isFile() || json.parse(path) != expected) {
102+
throw new GradleException("Missing or incorrect processed ore model: ${id}")
103+
}
104+
}
105+
hosts.keySet().each { id ->
106+
def packaged = new File(root, "textures/blocks/ore_overlays/${id}.png")
107+
if (!packaged.isFile() || !Arrays.equals(packaged.bytes, textures.file("${id}.png").asFile.bytes)) {
108+
throw new GradleException("Missing or changed processed ore overlay: ${id}")
109+
}
110+
}
111+
}
112+
}
113+
114+
tasks.named('check') { dependsOn verifyOreOverlayModels }

‎gradle/release/artifacts.gradle‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,13 @@ tasks.register('verifyReleaseArtifacts') {
189189
List<String> generatedRecipeAdvancements = currentInventory.findAll { String entry ->
190190
entry ==~ /assets\/basemetals\/advancements\/recipes\/materials\/[^\/]+\/[^\/]+\.json/
191191
}
192+
allowedAddedEntries.addAll([
193+
'com/mcmoddev/basemetals/block/OverlayOreBlock.class',
194+
'assets/basemetals/models/block/ore_overlay.json'
195+
])
196+
allowedAddedEntries.addAll(project.baseMetalsOreOverlayIds.collect {
197+
"assets/basemetals/textures/blocks/ore_overlays/${it}.png".toString()
198+
})
192199
allowedAddedEntries.addAll([
193200
'this_is_new', 'blocktastic', 'geologist', 'metallurgy',
194201
'aquarium_maker', 'brass_maker', 'bronze_maker', 'cupronickel_maker',

‎gradle/verification/support.gradle‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ tasks.register('verifyReleaseConfiguration') {
8282
description = 'Validates the complete Base Metals 1.12 release identity and dependency contract.'
8383
dependsOn tasks.named('verifyReleaseToolchains')
8484
doLast {
85-
if (project.mod_version != '2.6.2.112021'
85+
if (project.mod_version != '2.6.3.112021'
8686
|| project.minecraft_version != '1.12.2'
8787
|| project.forge_version != '14.23.5.2859'
8888
|| project.mappings_channel != 'stable'
@@ -130,7 +130,7 @@ tasks.register('verifyReleaseConfiguration') {
130130
throw new GradleException('Unexpected published OreSpawn 4.1 CurseForge artifact identity')
131131
}
132132
String source = file('src/main/java/com/mcmoddev/basemetals/BaseMetals.java').getText('UTF-8')
133-
if (!source.contains('VERSION = "2.6.2.112021"')
133+
if (!source.contains('VERSION = "2.6.3.112021"')
134134
|| !source.contains('certificateFingerprint = ""')
135135
|| !source.contains("required-after:orespawn@[${project.orespawn4_version},5.0.0)")) {
136136
throw new GradleException('Base Metals source version or unsigned fingerprint contract drifted')

‎src/main/java/com/mcmoddev/basemetals/BaseMetals.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public final class BaseMetals {
4545
protected static final String NAME = "Base Metals";
4646

4747
/** Release version in the shared MMD major.minor.patch.target format. */
48-
protected static final String VERSION = "2.6.2.112021";
48+
protected static final String VERSION = "2.6.3.112021";
4949

5050
protected static final String UPDATEJSON = SharedStrings.UPDATE_JSON_URL
5151
+ "BaseMetals/master/update.json";

0 commit comments

Comments
 (0)