Skip to content

Commit

Permalink
upd: Auto rename in conversion script
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonjgardner committed Mar 17, 2024
1 parent 4a062e8 commit 4b4b8fc
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/scripts/convert.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
$javaDir = "C:\Users\jason\AppData\Roaming\.minecraft\resourcepacks\PBR-JG\assets\minecraft\textures\block"
$javaDir = "..\java\pack\assets\minecraft\textures\block"
$sbar = "..\src\shelf\Converter.sbsar"

function GetJavaTextureNames {
$srcDir = "..\1.20.4\assets\minecraft\textures\block"

# Get the base name of all texture files in the source directory
$textures = Get-ChildItem -Path $srcDir -Filter "*.png" | ForEach-Object { [System.IO.Path]::GetFileNameWithoutExtension($_.FullName).ToLower() }

return $textures
}

function ConvertTexture {
param(
[Parameter(Mandatory = $true, Position = 0)]
Expand Down Expand Up @@ -66,10 +75,7 @@ function ConvertTexture {
Move-Item "$javaDir\$name`_n.png" "$javaDir\$dest`_n.png" -Force
}

# Get Java texture names from "javatextures.txt"
$javaTextures = Get-Content ".\src\scripts\javatextures.txt"

$javaTextureNames = $javaTextures | ForEach-Object { [System.IO.Path]::GetFileNameWithoutExtension($_).ToLower() }
$javaTextureNames = GetJavaTextureNames

$textureSets = Get-ChildItem -Path ".\bedrock\pack\RP\textures\blocks" -Filter "*.texture_set.json"

Expand All @@ -80,8 +86,12 @@ $textureSetNames = $textureSets | ForEach-Object { [System.IO.Path]::GetFileName
$selectedTextures = $textureSetNames | Out-GridView -Title "Select texture set to convert" -OutputMode Multiple

foreach ($texture in $selectedTextures) {
# Prompt for the Java texture name prior to conversion
$javaTexture = $javaTextureNames | Out-GridView -Title "Select Java texture name for $texture" -OutputMode Single
$javaTexture = $texture

# Prompt for the Java texture name prior to conversion if it is not found in the list
if (-not $javaTextureNames.Contains($texture)) {
$javaTexture = $javaTextureNames | Out-GridView -Title "Select Java texture name for $texture" -OutputMode Single
}

ConvertTexture $texture -dest "$javaTexture"
}

0 comments on commit 4b4b8fc

Please sign in to comment.