Last active
August 17, 2024 15:01
-
-
Save Aetopia/757e6e21562c6cef9852875c4170061b to your computer and use it in GitHub Desktop.
Particle Disabler: A dynamically generated resource pack that removes all vanilla particles for Minecraft: Bedrock Edition.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add-Type -AssemblyName System.IO.Compression.FileSystem | |
function _($Path) { return [System.Text.RegularExpressions.Regex]::Replace([System.IO.File]::ReadAllText($Path), "//.*?$|/\*[\s\S]*?\*/", "", [System.Text.RegularExpressions.RegexOptions]::Multiline) | ConvertFrom-Json } | |
if ($Package = (Get-AppxPackage | Where-Object { $_.PackageFamilyName -eq "Microsoft.MinecraftUWP_8wekyb3d8bbwe" }) ) { | |
Remove-Item "$ENV:TEMP\Particle Disabler" -Recurse -Force -ErrorAction SilentlyContinue | |
[System.IO.Directory]::CreateDirectory("$ENV:TEMP\Particle Disabler\particles") | Out-Null | |
$MaxEngineVersion = [System.Version]::new() | |
(Get-ChildItem "$($Package.InstallLocation)\data\resource_packs\*\manifest.json" -Recurse).FullName | ForEach-Object { | |
$MinEngineVersion = [System.Version]::new((_($_))."header"."min_engine_version" -join ".") | |
if ($MaxEngineVersion -le $MinEngineVersion) { $MaxEngineVersion = $MinEngineVersion } | |
} | |
$Version = ($MaxEngineVersion.ToString()) -split '.', '0', 'SimpleMatch' | ForEach-Object { [int]$_ } | |
(Get-ChildItem "$($Package.InstallLocation)\data\resource_packs\*\particles" -Recurse) | ForEach-Object { | |
$Object = (_($_.FullName)) | |
@{ | |
"format_version" = $Object."format_version" | |
"particle_effect" = @{ | |
"description" = $Object."particle_effect"."description" | |
"components" = [ordered]@{ | |
"minecraft:emitter_rate_instant" = @{ "num_particles" = 0 } | |
"minecraft:emitter_rate_manual" = @{ "max_particles" = 0 } | |
"minecraft:emitter_rate_steady" = @{ "max_particles" = 0 } | |
} | |
} | |
} | ConvertTo-Json -Depth 100 -Compress | Out-File "$ENV:TEMP\Particle Disabler\particles\$($_.Name)" -Encoding utf8 | |
} | |
$Object = _("$($Package.InstallLocation)\data\resource_packs\vanilla\manifest.json") | |
$Object."header"."name" = "Particle Disabler for Minecraft $($Version -join '.')" | |
$Object."header"."description" = $Object."modules"[0]."description" = "A dynamically generated resource pack that disables all vanilla particles." | |
$Object."header"."uuid" = "d5a9ad60-e797-4d67-89ff-f8d5e5f5c306" | |
$Object."modules"[0]."uuid" = "ceceff37-2546-4c7f-9db6-686a3d4a6694" | |
$Object."header"."min_engine_version" = $Object."header"."version" = $Object."modules"[0]."version" = $Version | |
Set-Content -Path "$ENV:TEMP\Particle Disabler\manifest.json" $($Object | ConvertTo-Json -Depth 100 -Compress) | |
Remove-Item "$ENV:USERPROFILE\Downloads\$($Object."header"."name").mcpack" -ErrorAction SilentlyContinue | |
[System.IO.Compression.ZipFile]::CreateFromDirectory("$ENV:TEMP\Particle Disabler", "$ENV:USERPROFILE\Downloads\$($Object."header"."name").mcpack", [System.IO.Compression.CompressionLevel]::Optimal, $false) | |
Remove-Item "$ENV:TEMP\Particle Disabler" -ErrorAction SilentlyContinue -Recurse -Force | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment