$ErrorActionPreference = 'Stop' $root = Join-Path $PSScriptRoot '../src/main/resources/defaults' function Write-Json($relative, $value) { $path = Join-Path $root $relative New-Item -ItemType Directory -Force (Split-Path $path) | Out-Null $value | ConvertTo-Json -Depth 30 | Set-Content -LiteralPath $path -Encoding utf8NoBOM } function Rail-Model($age, $on, $shape) { $slope = $shape.StartsWith('ascending_') $height = if ($slope) { 9.04 } else { 1.04 } $angle = if ($shape -in @('ascending_south','ascending_west')) { -45 } else { 45 } $elements = @() foreach ($strip in @(@(0,16,'#rail'),@(2,4,'#copper'),@(12,14,'#copper'))) { $y = $height + $(if ($strip[2] -eq '#copper') { .02 } else { 0 }) $uv = if ($strip[2] -eq '#copper') { @(4,0,6,16) } else { @(0,0,16,16) } $element = @{from=@($strip[0],$y,0);to=@($strip[1],$y,16);faces=@{ up=@{uv=$uv;texture=$strip[2]};down=@{uv=$uv;texture=$strip[2]} }} if ($slope) { $element.rotation=@{origin=@(8,9,8);axis='x';angle=$angle;rescale=$true} } $elements += $element } $copper = @('copper_block','exposed_copper','weathered_copper','oxidized_copper')[$age] $rail = if($on) {'powered_rail_on'} else {'powered_rail'} return @{ambientocclusion=$false;textures=@{rail="minecraft:block/$rail";copper="minecraft:block/$copper";particle="minecraft:block/$copper"};elements=$elements} } $prefixes = @('','exposed_','weathered_','oxidized_') $names = @('Медные рельсы','Потемневшие медные рельсы','Состаренные медные рельсы','Окисленные медные рельсы') $english = @('Copper Rail','Exposed Copper Rail','Weathered Copper Rail','Oxidized Copper Rail') $ru=@{}; $en=@{} for($age=0;$age -lt 4;$age++) { for($wax=0;$wax -lt 2;$wax++) { $id = $(if($wax) {'waxed_'} else {''})+$prefixes[$age]+'copper_rail' $name = $(if($wax) {'Вощёные: '} else {''})+$names[$age] $ru["item.astracontent.$id"]=$name $en["item.astracontent.$id"]=$(if($wax){'Waxed '}else{''})+$english[$age] Write-Json "resources/assets/astracontent/items/$id.json" @{model=@{type='minecraft:model';model="astracontent:item/$id"}} $model = Rail-Model $age $false 'north_south' $model.display=@{gui=@{rotation=@(35,0,0);translation=@(0,0,0);scale=@(1,1,1)};fixed=@{rotation=@(90,0,0)}} Write-Json "resources/assets/astracontent/models/item/$id.json" $model } foreach($shape in @('north_south','east_west','ascending_north','ascending_south','ascending_east','ascending_west')) { foreach($on in @($false,$true)) { $id="rail_display/$age/$shape"+$(if($on){'_on'}else{''}) Write-Json "resources/assets/astracontent/models/$id.json" (Rail-Model $age $on $shape) Write-Json "resources/assets/astracontent/items/$id.json" @{model=@{type='minecraft:model';model="astracontent:$id"}} } } } Write-Json 'resources/assets/astracontent/lang/ru_ru.json' $ru Write-Json 'resources/assets/astracontent/lang/en_us.json' $en Write-Json '../data/astracontent/recipe/copper_rail.json' @{ type='minecraft:crafting_shaped';pattern=@('X X','X#X','XRX');key=@{X='minecraft:copper_ingot';'#'='minecraft:stick';R='minecraft:redstone'} result=@{id='minecraft:powered_rail';count=6;components=@{ 'minecraft:custom_data'=@{'astracontent:rail'=0};'minecraft:item_model'='astracontent:copper_rail' 'minecraft:item_name'=@{translate='item.astracontent.copper_rail';fallback='Медные рельсы'} }} } Write-Json '../data/astracontent/advancement/recipes/copper_rail.json' @{ parent='minecraft:recipes/root';criteria=@{copper=@{trigger='minecraft:inventory_changed';conditions=@{items=@(@{items='minecraft:copper_ingot'})}}} requirements=@(,@('copper'));rewards=@{recipes=@('astracontent:copper_rail')} } $root = (Resolve-Path $root).Path Get-ChildItem -LiteralPath $root -Recurse -File | Where-Object Name -ne 'index.txt' | ForEach-Object { [IO.Path]::GetRelativePath($root,$_.FullName).Replace('\','/') } | Sort-Object | Set-Content -LiteralPath (Join-Path $root 'index.txt') -Encoding utf8NoBOM