Skip to content

Commit

Permalink
fix: support new 24w34a (MC 1.21.2) shader directory layout expectations
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexTMjugador committed Nov 11, 2024
1 parent 4b45e32 commit ec26987
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ Versioning](https://semver.org/spec/v2.0.0.html).
- Include shaders consisting of a list of statements no longer have only their
first instruction transformed when minifying or prettifying, which broke the
semantics of the shader code.
- Fragment, vertex, and include shaders located outside
`assets/minecraft/shaders/core` and `assets/minecraft/shaders/program` are now
processed, enhancing compatibility with resource packs targeting Minecraft
24w34a (1.21.2) or newer. (Thanks _@swrds_ for reporting this issue!)
- The UTF-8 BOM is no longer automatically stripped from properties files, as
they should not be encoded in UTF-8 to begin with, and carrying on processing
with mismatched encodings may cause mojibake.
Expand Down
27 changes: 12 additions & 15 deletions packages/packsquash/src/pack_file/asset_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,20 +388,17 @@ impl PackFileAssetType {
sky/world[0-9]*/moon_phases.properties}"
),

// Current Minecraft versions are only able to read shaders from the Minecraft
// namespace. However, this is likely to change in the future, and there might
// be mods that add shaders in other namespaces. To support such mods as long
// as they put their shaders in the core and program subdirectories, and future-
// proof our patterns, accept any namespace. It is also worth noting that, to
// compute the resource location the shader, render program and pipeline
// definition files are read from, Minecraft performs a simple string
// concatenation of a prefix path, the file name and the extension. Therefore,
// subdirectories are possible
// Older Minecraft versions were only able to read shaders from the Minecraft namespace,
// but versions since 24w34a (1.21.2) can read shaders from any namespace. That version
// also allowed shaders to be within any subdirectory of the "shaders" directory. While
// older Minecraft versions didn't have this flexibility, we're not enforcing that here
// to extend compatibility with hypothetical mods that might have added this feature before
// it was officially supported
Self::VertexShader => {
compile_hardcoded_pack_file_glob_pattern("assets/*/shaders/{core,program}/**/?*.vsh")
compile_hardcoded_pack_file_glob_pattern("assets/*/shaders/**/?*.vsh")
}
Self::FragmentShader => {
compile_hardcoded_pack_file_glob_pattern("assets/*/shaders/{core,program}/**/?*.fsh")
compile_hardcoded_pack_file_glob_pattern("assets/*/shaders/**/?*.fsh")
}
Self::TranslationUnitSegment => {
// Even though such possibility is not used in the vanilla resource pack,
Expand All @@ -414,10 +411,10 @@ impl PackFileAssetType {
// "post-processing shaders") can't import translation unit segments as of
// 1.17.1: it's simply just not implemented. We're not sure why Mojang did
// not just reuse the same code for both types of shaders, as the importing
// preprocessor code looks generic enough to handle both types just fine
compile_hardcoded_pack_file_glob_pattern(
"assets/*/shaders/{core,program,include}/**/?*.glsl"
)
// preprocessor code looks generic enough to handle both types just fine.
// This stopped being a quirk in 24w34a at the latest, the snapshot when the
// same GLSL preprocessor code for resolving imports was used for all shaders
compile_hardcoded_pack_file_glob_pattern("assets/*/shaders/**/?*.glsl")
}

Self::LegacyLanguageFile => {
Expand Down

0 comments on commit ec26987

Please sign in to comment.