Add subtle pixel shading to combined soup bowls

This commit is contained in:
2026-09-11 18:12:14 +03:00
parent cee738506d
commit 3048e310a9
7 changed files with 194 additions and 13 deletions
@@ -2,10 +2,17 @@ package online.astradev.cauldron;
import java.io.IOException;
import java.nio.file.*;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.HexFormat;
import java.util.List;
import static java.nio.charset.StandardCharsets.UTF_8;
/** Export before AstraPlus's startup pack build; never overwrite administrator resources. */
/** Export before AstraPlus's startup pack build; upgrade only known, unmodified defaults. */
final class SoupResources {
// Bundled flat-colour model in 0.2.0–0.2.3, with normalized newlines and outer whitespace.
private static final String FLAT_MODEL_SHA256 =
"51b5c2b0561ec815e5ddaff5654ce04fffa0995fc3e5972323f385d58842cd2c";
private SoupResources() {}
static void install(Path root) throws IOException {
for (String name : List.of("items/combined_soup.json",
@@ -13,11 +20,27 @@ final class SoupResources {
String relative = "assets/astradev_soups/" + name;
Path target = root.resolve("astraplus/resources").resolve(relative);
Files.createDirectories(target.getParent());
if (Files.exists(target)) continue;
boolean exists = Files.exists(target, LinkOption.NOFOLLOW_LINKS);
if (exists && !(name.equals("models/item/soup_liquid.json") && isFlatDefault(target))) continue;
try (var input = SoupResources.class.getResourceAsStream("/astra-resources/" + relative)) {
if (input == null) throw new IOException("Missing resource " + relative);
Files.copy(input, target);
if (!exists) Files.copy(input, target);
else {
Path temp = Files.createTempFile(target.getParent(), "soup-model-", ".tmp");
try {
Files.copy(input, temp, StandardCopyOption.REPLACE_EXISTING);
Files.move(temp, target, StandardCopyOption.ATOMIC_MOVE, StandardCopyOption.REPLACE_EXISTING);
} finally { Files.deleteIfExists(temp); }
}
}
}
}
private static boolean isFlatDefault(Path path) throws IOException {
if (!Files.isRegularFile(path, LinkOption.NOFOLLOW_LINKS) || Files.size(path) > 8192) return false;
String model = Files.readString(path, UTF_8).replace("\r\n", "\n").trim();
try {
return HexFormat.of().formatHex(MessageDigest.getInstance("SHA-256")
.digest(model.getBytes(UTF_8))).equals(FLAT_MODEL_SHA256);
} catch (NoSuchAlgorithmException impossible) { throw new AssertionError(impossible); }
}
}
@@ -2,6 +2,7 @@
"gui_light": "front",
"textures": {
"white": "minecraft:item/bone_meal",
"grey": "minecraft:item/iron_ingot",
"particle": "minecraft:item/bowl"
},
"display": {
@@ -13,24 +14,73 @@
},
"elements": [
{
"from": [5, 9, 7.49], "to": [11, 10, 8.51], "shade": false,
"from": [5, 9, 7.49], "to": [6, 10, 8.51], "shade": false,
"faces": {
"north": { "uv": [4.4, 2.4, 4.6, 2.6], "texture": "#white", "tintindex": 0 },
"south": { "uv": [4.4, 2.4, 4.6, 2.6], "texture": "#white", "tintindex": 0 }
}
},
{
"from": [6, 9, 7.49], "to": [9, 10, 8.51], "shade": false,
"faces": {
"north": { "uv": [4.4, 3.4, 4.6, 3.6], "texture": "#white", "tintindex": 0 },
"south": { "uv": [4.4, 3.4, 4.6, 3.6], "texture": "#white", "tintindex": 0 }
}
},
{
"from": [3, 8, 7.49], "to": [13, 9, 8.51], "shade": false,
"from": [9, 9, 7.49], "to": [11, 10, 8.51], "shade": false,
"faces": {
"north": { "uv": [4.4, 2.4, 4.6, 2.6], "texture": "#white", "tintindex": 0 },
"south": { "uv": [4.4, 2.4, 4.6, 2.6], "texture": "#white", "tintindex": 0 }
}
},
{
"from": [3, 8, 7.49], "to": [4, 9, 8.51], "shade": false,
"faces": {
"north": { "uv": [8.4, 4.4, 8.6, 4.6], "texture": "#grey", "tintindex": 0 },
"south": { "uv": [8.4, 4.4, 8.6, 4.6], "texture": "#grey", "tintindex": 0 }
}
},
{
"from": [4, 8, 7.49], "to": [7, 9, 8.51], "shade": false,
"faces": {
"north": { "uv": [4.4, 3.4, 4.6, 3.6], "texture": "#white", "tintindex": 0 },
"south": { "uv": [4.4, 3.4, 4.6, 3.6], "texture": "#white", "tintindex": 0 }
}
},
{
"from": [4, 7, 7.49], "to": [12, 8, 8.51], "shade": false,
"from": [7, 8, 7.49], "to": [10, 9, 8.51], "shade": false,
"faces": {
"north": { "uv": [4.4, 3.4, 4.6, 3.6], "texture": "#white", "tintindex": 0 },
"south": { "uv": [4.4, 3.4, 4.6, 3.6], "texture": "#white", "tintindex": 0 }
"north": { "uv": [4.4, 2.4, 4.6, 2.6], "texture": "#white", "tintindex": 0 },
"south": { "uv": [4.4, 2.4, 4.6, 2.6], "texture": "#white", "tintindex": 0 }
}
},
{
"from": [10, 8, 7.49], "to": [13, 9, 8.51], "shade": false,
"faces": {
"north": { "uv": [8.4, 4.4, 8.6, 4.6], "texture": "#grey", "tintindex": 0 },
"south": { "uv": [8.4, 4.4, 8.6, 4.6], "texture": "#grey", "tintindex": 0 }
}
},
{
"from": [4, 7, 7.49], "to": [6, 8, 8.51], "shade": false,
"faces": {
"north": { "uv": [8.4, 4.4, 8.6, 4.6], "texture": "#grey", "tintindex": 0 },
"south": { "uv": [8.4, 4.4, 8.6, 4.6], "texture": "#grey", "tintindex": 0 }
}
},
{
"from": [6, 7, 7.49], "to": [9, 8, 8.51], "shade": false,
"faces": {
"north": { "uv": [4.4, 2.4, 4.6, 2.6], "texture": "#white", "tintindex": 0 },
"south": { "uv": [4.4, 2.4, 4.6, 2.6], "texture": "#white", "tintindex": 0 }
}
},
{
"from": [9, 7, 7.49], "to": [12, 8, 8.51], "shade": false,
"faces": {
"north": { "uv": [8.4, 4.4, 8.6, 4.6], "texture": "#grey", "tintindex": 0 },
"south": { "uv": [8.4, 4.4, 8.6, 4.6], "texture": "#grey", "tintindex": 0 }
}
}
]