This repository was archived by the owner on Aug 10, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmatject.bat
More file actions
1735 lines (1580 loc) · 59.9 KB
/
matject.bat
File metadata and controls
1735 lines (1580 loc) · 59.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
:: A material replacer for Minecraft.
:: Made by github.com/faizul726, licence issued by YSS Group
:: https://faizul726.github.io/matject
@echo off
setlocal enabledelayedexpansion
:: Initial setup
title Loading...
cls
echo [?25lLoading...
pushd "%~dp0"
set "murgi=KhayDhan"
:: This script uses ANSI escape codes for text formatting.
:: "" = Hex 0x1B / Decimal 27
:: https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797
:: Mostly referenced as variables from "modules\colors.bat"
:: Although I used raw escape codes in some places.
:: Starting from v3.5.2, I also added BEL symbol "" = Hex 0x07 / Decimal 7
:: Which just plays 'Windows Foreground.wav' or 'Critical Stop' or 'beep' in some confirmation screens.
REM TODO
REM - STORE SHADER NAME FOR LATER USE [DONE]
REM - MERGE UNLOCK...BAT WITH MATJECT
REM - Use subroutines
REM - Use %1 for restoreMaterials
REM - L24, L34, unlockWindowsApps: use && ||
REM - Check -> Checker
REM - curl redirect stderr to stdout
REM - Move common functions to different file
REM - Use cscript for vbs [DONE]
REM - Use for %%f for colors to set variables
REM - Use start /b trickery for iobit window closing [DONE]
REM - Change up to date to you are using latest version something... [DONE]
:: Check critical components
if defined comspec (
if /i "%comspec:~-8,8%" neq "\cmd.exe" (
:comspec_error
cls
echo [91m[^^!] Matject is not compatible with your PC.
echo Reason: %%ComSpec%% environment variable doesn't use cmd.exe
echo DO NOT TRY TO FIX IT YOURSELF.[0m
echo.
echo Exiting...[?25h
echo.
endlocal
echo on
@cmd /k
)
) else (
goto comspec_error
)
:: Made possible thanks to https://stackoverflow.com/a/19777616
>nul 2>&1 where /? || (
cls
echo [91m[^^!] Matject is not compatible with your PC.
echo Reason: 'where' is missing.
echo DO NOT TRY TO ADD IT YOURSELF.[0m
echo.
echo Exiting...[?25h
echo.
endlocal
echo on
@cmd /k
)
:: Made possible thanks to https://stackoverflow.com/a/4781795
rem set "where_exists="
rem for %%X in (where.exe) do (set "where_exists=%%~$PATH:X")
rem if not defined where_exists goto where_error
>nul 2>&1 where certutil || (
cls
echo [91m[^^!] Matject is not compatible with your PC.
echo Reason: 'certutil' is missing.
echo DO NOT TRY TO ADD IT YOURSELF.[0m
echo.
echo Exiting...[?25h
echo.
endlocal
echo on
@cmd /k
)
>nul 2>&1 where findstr || (
cls
echo [91m[^^!] Matject is not compatible with your PC.
echo Reason: 'findstr' is missing.
echo DO NOT TRY TO ADD IT YOURSELF.[0m
echo.
echo Exiting...[?25h
echo.
endlocal
echo on
@cmd /k
)
>nul 2>&1 where find || (
cls
echo [91m[^^!] Matject is not compatible with your PC.
echo Reason: 'find' is missing.
echo DO NOT TRY TO ADD IT YOURSELF.[0m
echo.
echo Exiting...[?25h
echo.
endlocal
echo on
@cmd /k
)
>nul 2>&1 where clip || (
cls
echo [91m[^^!] Matject is not compatible with your PC.
echo Reason: 'clip' is missing.
echo DO NOT TRY TO ADD IT YOURSELF.[0m
echo.
echo Exiting...[?25h
echo.
endlocal
echo on
@cmd /k
)
>nul 2>&1 where forfiles || (
cls
echo [91m[^^!] Matject is not compatible with your PC.
echo Reason: 'forfiles' is missing.
echo DO NOT TRY TO ADD IT YOURSELF.[0m
echo.
echo Exiting...[?25h
echo.
endlocal
echo on
@cmd /k
)
rem >nul 2>&1 where msg || (
rem cls
rem echo [91m[^^!] Matject is not compatible with your PC.
rem echo Reason: 'msg' is missing.
rem echo DO NOT TRY TO ADD IT YOURSELF.[0m
rem echo.
rem echo Exiting...[?25h
rem echo.
rem endlocal
rem echo on
rem @cmd /k
rem )
>nul 2>&1 where powershell || (
cls
echo [91m[^^!] Matject is not compatible with your PC.
echo Reason: Mandatory component 'PowerShell' is missing.
echo DO NOT TRY TO ADD IT YOURSELF.[0m
echo.
echo Exiting...[?25h
echo.
endlocal
echo on
@cmd /k
)
echo %cd% | findstr /C:"Local\Temp" /I >nul && (
title EXTRACT FIRST^^!
cls
echo [93m[^^!] Are you trying to run Matject without extracting?
echo You have to extract it first^^![0m
echo.
echo Exiting...[?25h
echo.
endlocal
echo on
@cmd /k
)
if not exist "%cd%\matject.bat" (
title FOLDER NOT FOUND^^!
cls
echo [93m[^^!] Couldn't get Matject folder automatically[0m
echo.
echo Exiting...[?25h
echo.
endlocal
echo on
@cmd /k
)
:: Check admin status
>nul 2>&1 where fltmc && (
>nul 2>&1 fltmc && (set isAdmin=true) || (set "isAdmin=")
) || (
>nul 2>&1 where openfiles && (
>nul 2>&1 openfiles && (set isAdmin=true) || (set "isAdmin=")
) || (
>nul 2>&1 where wmic && (
>nul 2>&1 (wmic /locale:ms_409 service where ^(name="LanManServer"^) get state /value 2>nul | findstr /i "State=Running" >nul 2>&1)
if %errorlevel% equ 0 (
>nul 2>&1 net session && (set isAdmin=true) || (set "isAdmin=")
) else (set "isAdmin=")
) || (set "isAdmin=")
)
)
if "[%~1]" equ "[]" (
if exist ".settings\runAsAdmin.txt" (
:runSelfAsAdmin
cls
echo [93m[*] Reopening Matject as admin...[0m
echo.
if not defined isAdmin (
if exist ".settings\runAsAdmin_helper.vbs" (
echo [93m[^^!] Cancelling admin permission request will close Matject.[0m
if exist ".settings\matject_icon.ico" (
if exist ".settings\Matject.lnk" (
cscript /NoLogo ".settings\runAsAdmin_helper.vbs" majet ".settings\Matject.lnk"
exit 0
)
)
cscript /NoLogo ".settings\runAsAdmin_helper.vbs" majet "%~f0"
exit 0
) else (
if exist ".settings\matject_icon.ico" (
if exist ".settings\Matject.lnk" (
powershell -NoProfile -Command Start-Process -FilePath '.settings\Matject.lnk' -ArgumentList 'pwsh' -Verb runAs && exit 0 || goto runAsAdminPwshFailure
)
)
powershell -NoProfile -Command Start-Process -FilePath 'matject.bat' -ArgumentList 'pwsh' -Verb runAs && exit 0 || (
:runAsAdminPwshFailure
del /q ".\.settings\runAsAdmin.txt" >nul 2>&1
echo [91m[^^!] Failed to reopen Matject as admin.
echo.
echo [93m[*] Disabled "Run as admin always" to allow normal access to Matject.[0m
echo.
echo [*] You may want to open Matject again.
echo.
echo Press any key to exit...
pause >nul
exit 1
)
)
) else (
goto alreadyRanAsAdmin
)
) else (
:alreadyRanAsAdmin
if exist ".settings\matject_icon.ico" (
if exist ".settings\Matject.lnk" (
start /i "Loading..." "%cd%\.settings\Matject.lnk" placebo
exit 0
)
)
start /i /b "Loading..." cmd /k "%~f0" placebo
exit 0
)
) else (
if "[%~1]" equ "[pwsh]" (
start /i /b "Loading..." cmd /k "%~f0" placebo
exit 0
)
if exist ".settings\runAsAdmin.txt" (
if not defined isAdmin (
goto runSelfAsAdmin
)
)
)
>nul 2>&1 where mode || (
set "useSplash="
goto skip_splash
)
:: Setup splash screen
set "useSplash=true"
set "window_height="
set "window_width="
:: for /f "tokens=2 delims=:" %%a in ('mode con ^| findstr "Columns"') do set "window_width=%%a"
:: for /f "tokens=2 delims=:" %%a in ('mode con ^| findstr "Lines"') do set "window_height=%%a"
for /f "tokens=2" %%N in ('mode con ^| find "Columns"') do set /a window_width=(%%N-18)/2
for /f "tokens=2" %%N in ('mode con ^| find "Lines"') do set /a window_height=(%%N-12)/2
if window_width leq 0 (set /a window_width=51)
if window_height leq 0 (set /a window_height=9)
if window_height geq 1000 (set /a window_height=9)
:: set /a window_width=%window_width%-18/2
:: set /a window_height=(%window_height%-12)/2
for /L %%I in (1,1,!window_width!) do (set "x_spacer=!x_spacer! ")
for /L %%I in (1,1,!window_height!) do (set "y_spacer=& echo: !y_spacer!")
:: Splash screen
cls
%y_spacer:~2%
set "p1=[107m [0m"
echo !x_spacer!!p1!!p1!!p1!!p1!!p1! !p1!!p1!!p1!
echo !x_spacer!!p1! !p1!
echo !x_spacer!!p1! !p1! !p1! !p1!
echo !x_spacer!!p1! !p1! !p1!
echo !x_spacer!!p1! !p1!!p1!!p1! !p1!
echo.
if exist ".\.settings\ranOnce.txt" (
echo !x_spacer!!x_spacer:~0,4!Loading...
) else (
title Welcome^^!
echo !x_spacer:~0,-10!Welcome to Matject for the first time^^!
echo.
echo !x_spacer:~0,-5![90mPress any key to continue...[0m
pause >nul
)
:skip_splash
:: Verify modules
:: All %%h things have two things, lastEightCharactersOfSHA256-FILENAME
:: It checks if the file exists and then compare with its SHA256
if not exist ".settings\disableModuleVerification.txt" (
title Matject: Verifying modules...
if defined useSplash (
echo [1F[0J!x_spacer:~0,-3![93m[*] Verifying modules...[0m
) else (
cls
set "fileHash="
echo [93m[*] Verifying modules...[0m
)
:: Make all *.bat files read only
if not exist ".settings\dontMakeReadOnly.txt" (
for %%F in ("matject.bat" ".\.settings\*.vbs" ".\modules\*" ".\modules\matjectNEXT\*.bat") do (attrib +R "%%~fF" >nul 2>&1)
)
for %%h in (0b99d813-0_debug 5956fd4c-about b04562e7-autoject c4671b44-backupMaterials e5ab8ef8-checkMaterialCompatibility 006c4556-checkUpdates a929f392-clearVariable fa337c50-colors b3d46c5e-createIcon 59817bfa-createShortcut c39ca84e-createTarget e87fb00c-getMaterialUpdater 27d6b1b2-getMatjectAnnouncement 1a006390-getMinecraftDetails eb316e31-help a1cce537-matjectExamEditionReal fe068270-matjectTips e90a02f8-matjectUpdater 9a1c86c2-noobMode 1eb19df1-progressBar 39aa680e-restoreMaterials 46e769e7-settings 53ec30cd-settingsV3 245775ec-taskkillLoop 1470568e-unlockWindowsApps b700e034-updateMaterials 63572ab4-variables 29d21467-matjectNEXT\cachePacks d0281286-matjectNEXT\getJQ 5c48c003-matjectNEXT\injectMaterials 6de66c54-matjectNEXT\listMaterials 0fc807a6-matjectNEXT\main df2b6cd9-matjectNEXT\manifestChecker e63fc0da-matjectNEXT\parsePackVersion 6489d832-matjectNEXT\parsePackWithCache 20e0f133-matjectNEXT\parseSubpack 50265baa-matjectNEXT\syncMaterials 548ff3f3-matjectNEXT\testCompatibility) do (
set "fileToHash=%%h"
rem echo !fileToHash:~9! = !fileToHash:~0,8!
if not exist "modules\!fileToHash:~9!.bat" (
title MODULE NOT FOUND^^!
cls
echo [91m[^^!] MODULE IS MISSING.[90m ^(modules\!fileToHash:~9!.bat^)[0m
echo.
echo [93m[^^!] Don't try to fix it yourself if you are not smart enough.
echo Download Matject again from [96mgithub.com/faizul726/matject[93m instead.[0m
echo.
echo Exiting...[?25h
echo.
endlocal
echo on
@cmd /k
) else (
for /f "tokens=*" %%A in ('certutil -hashfile "modules\!fileToHash:~9!.bat" SHA256 ^| findstr /v ":"') do (
set "fileHash=%%A"
if /i "!fileHash:~56,8!" neq "!fileToHash:~0,8!" (
title MODULE ISSUE^^!
cls
echo [91m[^^!] MODULE IS EITHER MODIFIED OR CORRUPTED.[90m ^(modules\!fileToHash:~9!.bat^)[0m
echo.
echo [93m[^^!] Don't try to fix it yourself if you are not smart enough.
echo Download Matject again from [96mgithub.com/faizul726/matject[93m instead.[0m
echo.
echo [90mDetails: "!fileHash:~56,8!" NEQ "!fileToHash:~0,8!"[0m
echo.
echo Exiting...[?25h
echo.
endlocal
echo on
@cmd /k
)
)
)
)
set "fileHash="
if defined useSplash (
echo [1F[0J!x_spacer:~0,-2![92m[*] All modules are OK[0m
) else (
echo [1F[0J[92m[*] All modules are OK[0m
)
timeout 1 >nul
)
::echo. & echo [93mPAUSE FOR TESTING. PRESS ANY KEY TO RESUME...[0m & echo. & pause >nul
:: Change code page to support non-English character
for /f "tokens=4" %%c in ('chcp') do (
set chcp_default=%%c
>nul 2>&1 chcp 65001 && set "chcp_failed=" || (
set chcp_failed=true
chcp %%c >nul 2>&1
)
)
:: Load other variables
call "modules\colors"
if exist ".settings\useForMinecraftPreview.txt" (
set "isPreview= ^(Preview Mode^)"
set "preview= Preview"
) else (
set "isPreview="
set "preview="
)
call "modules\variables"
if not exist ".settings\*" (call "modules\createTarget" folder ".settings")
call "modules\settingsV3"
if exist ".settings\debugMode.txt" (set "debugMode=true") else (set "debugMode=")
:: It's tricky to do logical OR in Windows Batch.
:: So, using weird variable to make sure 'if exist tar' fails.
if not defined mt_fallbackToExpandArchive (set "tarexe=tar.exe") else (set "tarexe=confused_unga/bunga")
:: SET VERSION AND WINDOW TITLE
::set "dev=-dev ^(20250415^)"
set "version=v3.7.0"
set "title=Matject %version%%dev%%isPreview%"
title %title%
:: WORK DIRECTORY SETUP
:: if not exist ".settings\*" (mkdir .settings)
if not exist ".settings\.DO-NOT-EDIT-ANYTHING-HERE.txt" (call "modules\createTarget" ".settings\.DO-NOT-EDIT-ANYTHING-HERE.txt" "echo DO NOT modify any files in this folder unless you have proper knowledge.")
if not exist "MCPACKS\*" (call "modules\createTarget" folder "MCPACKS")
if exist "MCPACKS\put-mcpacks-or-zips-here" (del /q ".\MCPACKS\put-mcpacks-or-zips-here" > NUL)
if not exist "MATERIALS\*" (call "modules\createTarget" folder "MATERIALS")
if exist "MATERIALS\put-materials-here" (del /q ".\MATERIALS\put-materials-here" > NUL)
if exist "tmp\*" (rmdir /q /s ".\tmp" > NUL)
if not defined matbak (
title VARIABLE ISSUE^^!
cls
echo [91m[^^!] Variable issue: matbak[0m
echo.
echo Exiting...[?25h
echo.
endlocal
echo on
@cmd /k
)
rem if exist ".\Backups!matbak:~7!" (
rem if not exist ".\Backups!matbak:~7!\*.material.bin" (
rem rmdir /q /s ".\Backups!matbak:~7!"
rem rem if exist "%rstrList%" (>nul del /q ".\%rstrList%")
rem rem if exist "%lastMCPACK%" del /q /s ".\%lastMCPACK%" >nul
rem rem if exist "%lastRP%" del /q /s ".\%lastRP%" >nul
rem )
rem )
:: if not exist logs (mkdir logs)
if defined debugMode call "modules\createTarget" "folder" "logs"
if defined mt_useMaterialUpdater (
if not exist "modules\material-updater.exe" (call "modules\settingsV3" clear mt_useMaterialUpdater)
)
>nul 2>&1 where curl || (
call "modules\settingsV3" clear mt_doCheckUpdates
call "modules\settingsV3" clear mt_showAnnouncements
)
if exist "%ranOnce%" (
set /p memoire=<"%ranOnce%"
if exist "%letters%_!memoire!.ini" (set "memoire=" & goto firstRunDone) else (set "memoire=" & del /q /f ".\%ranOnce%" >nul 2>&1)
)
cls
echo !WHT!=== Matject Terms of Use ===!RST!
echo.
if not exist "TERMS.md" (
echo !RED![^^!] "TERMS.md" not found.!RST!
%exitMsg%
)
type TERMS.md
echo.
echo.
echo !GRY!Maximize the window to read properly!RST!
echo.
echo !YLW![?] Do you accept the terms of use above?!RST!
echo.
echo !RED![Y] Yes !GRN![N] No, exit
choice /c yn /n >nul
if %errorlevel% neq 1 exit /b 403
cls
echo !WHT!Welcome to %title%^^!!RST! ^(for the very first time^)
echo.
echo.
echo !ERR!=== Please read this carefully^^! ===!RST!
echo.
echo - Matject is pretty stable now, yet you may run into issues.
echo Please report on GitHub or Discord server: !CYN!faizul726.github.io/bedrockgraphics-discord!RST!
echo - It needs unmodified materials to ensure shader removal works properly.
echo If you have modified already and don't have original ones, get from !CYN!mcpebd.github.io/materials!RST!
echo - DO NOT MODIFY .settings, Backups, modules folder.
echo - Some antivirus may prevent Matject from working properly. Turning it off or whitelisting may help.
echo - IObit Unlocker may crash on some PCs for no reason. In that case Matject won't work.
echo - Matject doesn't enable Deferred/Vibrant Visuals/PBR/RTX, nor patch your game.
echo - Disabling resource pack or deleting Matject won't remove shaders. Use Shader Removal in main screen to remove.
echo - DO NOT USE THIS, IF IT'S NOT FROM !CYN!%githubLink:~8,-1%!RST!
echo That's the one and only official source. Avoid downloading from random links/YouTube.
echo - English is not my primary language. So, grammatical errors are expected.!RST!
echo !YLW!- By using Matject, you agree to the license terms provided by YSS Group. ^(See TERMS.md^)!RST!
echo.
echo %showCursor%
set /p "firstRun=Type !RED!understood!RST! and press [Enter] to confirm:!GRN! "
echo %hideCursor%
if not defined firstRun (
echo !ERR![^^!] Input can't be empty!RST!
%exitmsg%
)
if "%firstRun: =%" neq "understood" (
echo !ERR![^^!] Wrong input!RST!
%exitmsg%
) else (
echo !GRN![*] Confirmed.!RST!
timeout 2 > NUL
call "modules\matjectExamEditionReal"
cls
echo Matject is somewhat experimental.
echo So, it's better to use the latest version whenever possible.
echo.
echo !YLW![?] Do you want to check for updates at Matject startup?!RST! !YLW!^(requires internet^)!RST!
echo.
echo !GRN![Y] Yes, check for updates at Matject startup. !GRY!^(updating is optional^)!RST!
echo !RED![N] No, do not check for updates.!RST!
echo.
echo !GRN![TIP]!RST! You can enable/disable update checking from Matject Settings -^> Updates ^& Debug later.
echo.
choice /c yn /n >nul
if !errorlevel! equ 1 call "modules\settingsV3" set mt_doCheckUpdates true
cls
echo !YLW![?] Do you want to make shortcuts of Matject?!RST!
echo.
echo !GRN![Y] Yes !GRY!^(Desktop and Start menu^)
echo !RED![N] No!RST!
echo.
echo !GRN![TIP]!RST! You can add/remove shortcuts from "Shader Removal/Tools" anytime.!RST!
echo.
choice /c yn /n >nul
if !errorlevel! equ 1 call "modules\createShortcut" all
cls
echo !YLW![?] Do you want to get material-updater?!RST!
echo.
echo It's a tool made by @mcbegamerxx954.
echo.
echo It automatically updates shader files to support latest version.
echo Also fixes well known "invisible blocks" issue.
echo.
echo !GRN![TIP]!RST! You can always enable/disable it from Matject Settings later.!RST!
echo.
echo !GRN![Y] Yes !RED![N] No!RST!
echo.
choice /c yn /n >nul
if !errorlevel! equ 1 call "modules\getMaterialUpdater" skip_intro
)
:firstRunDone
if defined mt_doCheckUpdates (call "modules\checkUpdates")
if defined mt_customIObitUnlockerPath (
if exist "!mt_customIObitUnlockerPath!\IObitUnlocker.exe" (
if exist "!mt_customIObitUnlockerPath!\IObitUnlocker.dll" (
set "IObitUnlockerPath=!mt_customIObitUnlockerPath!\IObitUnlocker.exe"
goto iobitUnlockerFound
)
)
) else (
goto checkIObitUnlocker
)
cls
echo !ERR![^^!] Provided custom IObit Unlocker path is invalid^^!!RST!
echo.
echo Press any key to remove...
echo.
pause >nul
call "modules\settings" toggleP2_3
:checkIObitUnlocker
if not exist "%ProgramFiles(x86)%\IObit\IObit Unlocker\IObitUnlocker.exe" (
cls
echo !BEL!!RED![^^!] It seems like you don't have IObit Unlocker installed.!RST!
echo It's required to use Matject.
echo.
echo !YLW![?] Would you like to download now?!RST!
echo.
echo [Y] Yes, open the site for me !CYN!^(www.iobit.com/en/iobit-unlocker.php^)!RST!
echo !RED![B] No, I will download later ^(exit^)!RST!
echo.
echo [P] I already have it installed, let me set custom path.
echo.
choice /c ybp /n >nul
cls
if !errorlevel! equ 1 (start https://www.iobit.com/en/iobit-unlocker.php & exit)
if !errorlevel! equ 2 (exit)
if !errorlevel! equ 3 (call "modules\settings" toggleP2_3)
) else (set "IObitUnlockerPath=%ProgramFiles(x86)%\IObit\IObit Unlocker\IObitUnlocker.exe")
:iobitUnlockerFound
if defined mt_customMinecraftAppPath (
if not exist "!mt_customMinecraftAppPath!\AppxManifest.xml" (
cls
echo !ERR![^^!] Custom Minecraft app path DOES NOT exist.!RST!
echo.
call "modules\getMinecraftDetails" failure
rem if exist %materialUpdaterArg% del /q .\%materialUpdaterArg% > NUL
call "modules\settingsV3" clear mt_materialUpdaterArg
set "useSplash="
) else (
set MCLOCATION=!mt_customMinecraftAppPath!
if defined mt_oldMinecraftVersion (
rem set /p CURRENTVERSION=<%oldMinecraftVersion%
rem set /p OLDVERSION=<%oldMinecraftVersion%
set "CURRENTVERSION=!mt_oldMinecraftVersion!"
set "OLDVERSION=!mt_oldMinecraftVersion!"
echo %hideCursor%>nul
) else (
if not defined chcp_failed (>nul 2>&1 chcp !chcp_default!)
for /f "tokens=*" %%i in ('powershell -NoProfile -command "(Get-AppxPackage -Name Microsoft.%productID%).Version"') do (set "CURRENTVERSION=%%i" & set "OLDVERSION=%%i")
if not defined chcp_failed (>nul 2>&1 chcp 65001)
)
)
) else (
cls
set "useSplash="
call "modules\getMinecraftDetails"
rem if exist %oldMinecraftVersion% (set /p OLDVERSION=<%oldMinecraftVersion%)
if defined mt_oldMinecraftVersion (
set "OLDVERSION=!mt_oldMinecraftVersion!"
)
echo %hideCursor%>nul
cls
)
if defined mt_customMinecraftDataPath (
if exist "!mt_customMinecraftDataPath!\minecraftpe\options.txt" (
set "gameData=!mt_customMinecraftDataPath!"
) else (
cls
call "modules\settingsV3" clear mt_customMinecraftDataPath
echo !ERR![^^!] Custom Minecraft data path invalid.
echo !RED!If it's correct then open the game at least once.
echo.
echo !YLW![*] Turned off custom Minecraft data path and using default data path.!RST!
set "useSplash="
echo.
pause
)
)
rem if not exist "%customMinecraftDataPath%" (goto nocustomgamedata)
rem set /p gameDataTMP=<%customMinecraftDataPath%
rem echo %hideCursor%>nul
rem if not exist "!gameDataTMP!\minecraftpe\options.txt" (
rem cls
rem set "gameDataTMP="
rem echo !ERR![^^!] Custom Minecraft data path invalid.!RST!
rem echo !RED!If it's correct then open the game at least once.
rem echo.
rem del /q ".\%customMinecraftDataPath%" >nul
rem echo !YLW![*] Turned off custom Minecraft data path and using default data path.!RST!
rem set "gameData=%defaultGameData%"
rem set "useSplash="
rem ) else (
rem set "gameData=!gameDataTMP!"
rem set "gameDataTMP="
rem )
:nocustomgamedata
if exist "%unlocked%" goto DELETEOLDBACKUP
:: Disabled this part because still unsure if sideloaded installation is actually outside %ProgramFiles%
:: Yes it is... But will need to add more changes to adjust dynamically with current unlock state. 20250414
:: if /i "%MCLOCATION:~0,28%" neq "C:\Program Files\WindowsApps" (
:: echo [%date% // %time:~0,-6%] - This file was created to indicate that WindowsApps is already unlocked and skip the question in Matject.>"%unlocked%"
:: )
if not exist "%unlocked%" (
cls
set "useSplash="
echo !BEL!!YLW![*] You don't have "%ProgramFiles%\WindowsApps" folder unlocked.!RST!
echo.
echo !RED!Without unlocking Matject CANNOT backup materials.!RST!
echo.
echo !YLW![?] Do you want to unlock?!RST!
echo.
echo !RED![Y] Yes ^(will request admin permission^)
echo !GRN![N] No ^(exit^)!RST!
echo.
choice /c yn /n >nul
echo.
if !errorlevel! equ 1 (
cls
title %title% ^(unlocking WindowsApps^)
echo !YLW!!BLINK![*] Unlocking WindowsApps folder...!RST!
if not defined chcp_failed (>nul 2>&1 chcp !chcp_default!)
powershell -NoProfile -command Start-Process -File 'modules\unlockWindowsApps.bat' -Verb runas -Wait || (
echo !YLW![*] Seems like automatic unlock failed.
echo You will need to go into the modules folder of Matject,
echo Right-click "unlockWindowsApps" and run it as admin.
)
if not defined chcp_failed (>nul 2>&1 chcp 65001)
echo.
if not exist %unlocked% (title %title% && echo !ERR![^^!] FAILED. Saved log in .settings\unlockLog.txt. You might need it for finding the issue later.!RST! && %exitmsg%) else (
echo !GRN![*] Unlocked.!RST!
timeout 2 >nul
)
echo.
) else (if "!errorlevel!" equ "2" exit)
)
:DELETEOLDBACKUP
if defined mt_directWriteMode (
(echo This file was created to check if Minecraft app folder is writable. [%date% // %time:~0,-6%]>"!MCLOCATION!\matject-test-file.txt") >nul 2>&1
if not exist "!MCLOCATION!\matject-test-file.txt" (
cls
echo !ERR![^^!] Unable to write directly in Minecraft app folder.!RST!
echo.
echo !YLW![*] Disabled "Direct write mode" to allow normal access to Matject.!RST!
call "modules\settingsV3" clear mt_directWriteMode
set "useSplash="
pause
) else (
del /q /f "!MCLOCATION!\matject-test-file.txt"
)
)
if exist "!backupRunning:~0,-4!.log" (
cls
set "useSplash="
echo !RED![^^!] Last backup was incomplete.!RST!
echo.
echo !YLW![*] Making new backup...!RST!
echo.
if exist ".\Backups!matbak:~7!" rmdir /q /s ".\Backups!matbak:~7!"
call "modules\backupMaterials"
)
if exist ".\Backups!matbak:~7!\*.material.bin" (
if "!CURRENTVERSION!" neq "!OLDVERSION!" (
cls
set "useSplash="
echo !RED![^^!] OLD SHADER BACKUP DETECTED.!RST!
echo.
echo !YLW![*] Current version: v!CURRENTVERSION!, old version: v!OLDVERSION!.!RST!
echo.
if defined mt_dontRetainOldBackups (
echo !YLW![*] Deleting old backup...!RST!
echo.
rmdir /q /s ".\Backups!matbak:~7!"
) else (
echo !YLW![*] Renaming old backup...!RST!
echo.
if exist "Old Materials Backup (v!OLDVERSION!)" (
rmdir /q /s ".\Backups!matbak:~0,19!\Old Materials Backup (v!OLDVERSION!)" >nul 2>&1
del /q /f ".\Backups!matbak:~0,19!\Old Materials Backup (v!OLDVERSION!)" >nul 2>&1
)
rename ".\Backups!matbak:~7!" "Old Materials Backup (v!OLDVERSION!)" >nul
)
rem if exist %materialUpdaterArg% del /q ".\%materialUpdaterArg%" > NUL
call "modules\settingsV3" clear mt_materialUpdaterArg
if exist "!taskOngoing:~0,-4!.log" del /q /f ".\!taskOngoing:~0,-4!.log" >nul
rem if exist "%rstrList%" del /q ".\%rstrList%" >nul
call "modules\settingsV3" clear mt_restoreList
rem if exist "%lastMCPACK%" del /q ".\%lastMCPACK%" >nul
call "modules\settingsV3" clear mt_lastMCPACK
rem if exist "%lastRP%" del /q ".\%lastRP%" >nul
call "modules\settingsV3" clear mtnxt_lastResourcePackID
rem if exist "%backupDate%" del /q ".\%backupDate%" >nul
call "modules\settingsV3" clear mt_currentBackupDate
rem echo !CURRENTVERSION!>%oldMinecraftVersion%
call "modules\settingsV3" set mt_oldMinecraftVersion "!CURRENTVERSION!"
call "modules\backupMaterials"
timeout 2 > NUL
)
) else (
cls
set "useSplash="
call "modules\backupMaterials"
)
rem for /f "tokens=2 delims==" %%a in ('"wmic os get localdatetime /value"') do (
rem set "deiteu=%%a"
rem set /a "imy=!deiteu:~2,2!-21"
rem set "deiteu=!deiteu:~4,4!"
rem )
rem Will add future April Fools Joke (100% real)
if defined mt_disableInterruptionCheck (
if exist "!taskOngoing:~0,-4!.log" del /q /f ".\!taskOngoing:~0,-4!.log" >nul
goto skipInterruptionCheck
)
if exist "!taskOngoing:~0,-4!.log" (
cls
echo !BEL!!YLW![*] Seems like last injection didn't go well...
echo.
echo [?] Do you want to perform a Full Restore?!RST!
echo.
echo !GRN![Y] Yes !RED![N] No!RST!
choice /c yn /n >nul
echo.
if !errorlevel! equ 1 (
cls
set "RESTORETYPE=full"
call "modules\restoreMaterials"
) else if !errorlevel! equ 2 (
cls
echo !RED![^^!] Matject may not work as expected if you don't perform a Full Restore...!RST!
del /q /f ".\!taskOngoing:~0,-4!.log" >nul
timeout 3 >nul
)
)
:skipInterruptionCheck
set "openingMethod="
set "x_spacer_openingMethod="
set "x_spacer_pressForSettings="
if defined mt_defaultMethod (
if /i "!mt_defaultMethod!" equ "Auto" set "openingMethod=!GRN!Auto!RST!" & set "x_spacer_openingMethod=!x_spacer:~0,-8!"
if /i "!mt_defaultMethod!" equ "Manual" set "openingMethod=!BLU!Manual!RST!" & set "x_spacer_openingMethod=!x_spacer:~0,-9!"
if /i "!mt_defaultMethod!" equ "matjectNEXT" set "openingMethod=!RED!matjectNEXT!RST!" & set "x_spacer_openingMethod=!x_spacer:~0,-12!"
if /i "!mt_defaultMethod!" neq "Auto" if /i "!mt_defaultMethod!" neq "Manual" if /i "!mt_defaultMethod!" neq "matjectNEXT" (
call "modules\settingsV3" clear mt_defaultMethod
goto INTRODUCTION
)
if defined useSplash (
set "x_spacer_pressForSettings=!x_spacer:~0,-12!"
) else (
set "x_spacer_openingMethod="
set "x_spacer_pressForSettings="
)
echo [1F[0K!x_spacer_openingMethod!Opening !openingMethod! method in 2 seconds...
echo.
echo !YLW!!x_spacer_pressForSettings!Press [S] to open Matject settings instead!RST!
choice /c s0 /t 2 /d 0 /n >nul
set "openingMethod="
set "x_spacer_openingMethod="
set "x_spacer_pressForSettings="
if !errorlevel! equ 1 goto option6
goto !mt_defaultMethod!
)
rem if exist "%defaultMethod%" (
rem set /p selectedMethod=<%defaultMethod%
rem echo %hideCursor%>nul
rem if defined selectedMethod (
rem set "selectedMethod=!selectedMethod: =!"
rem ) else (
rem set selectedMethod=null
rem )
rem
rem if /i "!selectedMethod!" neq "Auto" if /i "!selectedMethod!" neq "Manual" if /i "!selectedMethod!" neq "matjectNEXT" (
rem pause
rem echo [2F[0J
rem if defined useSplash (
rem echo !x_spacer:~0,-25!!RED![^^!] "%defaultMethod%" is invalid. Going to main screen...!RST!
rem ) else (
rem echo !RED![^^!] "%defaultMethod%" is invalid. Going to main screen...!RST!
rem )
rem del /q ".\%defaultMethod%" >nul
rem timeout 2 >nul
rem goto INTRODUCTION
rem )
rem if defined useSplash (
rem echo [2F[0J
rem if /i "!selectedMethod: =!" equ "Auto" echo !x_spacer:~0,-8!Opening !GRN!Auto!RST! method in 2 seconds...
rem if /i "!selectedMethod: =!" equ "Manual" echo !x_spacer:~0,-9!Opening !BLU!Manual!RST! method in 2 seconds...
rem if /i "!selectedMethod: =!" equ "matjectNEXT" echo !x_spacer:~0,-12!Opening !RED!matjectNEXT!RST! method in 2 seconds...
rem echo.
rem echo !YLW!!x_spacer:~0,-10!Press [S] to open settings directly...!RST!
rem ) else (
rem cls
rem if /i "!selectedMethod: =!" equ "Auto" echo !WHT![*] Opening !GRN!Auto!RST! method in 2 seconds...
rem if /i "!selectedMethod: =!" equ "Manual" echo !WHT![*] Opening !BLU!Manual!RST! method in 2 seconds...
rem if /i "!selectedMethod: =!" equ "matjectNEXT" echo !WHT![*] Opening !RED!matjectNEXT!RST! method in 2 seconds...
rem echo.
rem echo !YLW!Press [S] to open Matject Settings directly...!RST!
rem )
rem choice /c s0 /t 2 /d 0 /n >nul
rem if !errorlevel! equ 1 goto option6
rem cls
rem goto !selectedMethod!
rem )
:INTRODUCTION
set "x_spacer="
set "y_spacer="
set "usingCustomPath="
cls
if defined isAdmin (set "isAdmin=Running as admin. ")
for %%F in ("mt_customMinecraftAppPath" "mt_customMinecraftDataPath" "mt_customIObitUnlockerPath") do (
if defined %%~F set "usingCustomPath=true"
)
if exist "%useForMinecraftPreview%" (
if defined usingCustomPath (
echo !GRY![*] %isAdmin%Using for Minecraft Preview with custom path^(s^) enabled.!RST!
) else (
echo !GRY![*] %isAdmin%Using for Minecraft Preview.!RST!
)
echo.
) else (
if defined usingCustomPath (
echo !GRY![*] %isAdmin%Custom path^(s^) enabled.!RST!
echo.
) else if defined isAdmin (
echo !GRY![*] %isAdmin%!RST!
echo.
)
)
if defined mt_lastMCPACK (
set "tmp_lastMCPACK=!GRY!^(Last injected: !mt_lastMCPACK!^)!RST!"
) else (set "tmp_lastMCPACK=")
if defined mtnxt_lastResourcePackName (
set "mtnxt_lastResourcePackName_display=!GRY!^(Last injected: !mtnxt_lastResourcePackName!^)!RST!"
) else (set "mtnxt_lastResourcePackName_display=")
rem if "%deiteu%" equ "0726" echo !BLU!Happy birthday rwxrw-r-- U+1F337 ^(%imy%^)!RST!
set RESTORETYPE=
:: HOME SWEET HOME
:: START SCREEN
:: INIT
if %time:~0,2% geq 00 if %time:~0,2% lss 05 echo !WHT!You should sleep now.
if %time:~0,2% geq 05 if %time:~0,2% lss 12 echo !WHT!Good morning,
if %time:~0,2% geq 12 if %time:~0,2% lss 18 echo !WHT!Good afternoon,
if %time:~0,2% geq 18 if %time:~0,2% lss 22 echo !WHT!Good evening,
if %time:~0,2% geq 22 if %time:~0,2% lss 24 echo !WHT!Good night,
echo Welcome to %title: ^(Preview Mode^)=%^^!!RST! ^| !CYN!%githubLink:~8,-1%!RST!
echo.
if not defined mt_hideTips (
call modules\matjectTips
echo.
)
if defined mt_showAnnouncements (
echo !GRN![Announcement]!RST! Loading...
call modules\getMatjectAnnouncement
)
echo.
echo !YLW![?] Which method would you like to use?!RST!
echo.
echo !GRN![1] Auto!RST! !GRY![Deprecated]!RST! %tmp_lastMCPACK%
echo Put one or more MCPACK/ZIP files into the MCPACKS folder.
echo Matject will let you choose any one to extract materials from and then ask you to inject
echo.
echo !BLU![2] Manual!RST! !GRY![Deprecated]!RST!
echo Put .material.bin files into the MATERIALS folder.
echo Matject will ask you to inject provided materials.
echo.
echo !RED![3] matjectNEXT!RST! %mtnxt_lastResourcePackName_display%
if defined mt_restoreList (
echo Draco for Windows but not really. !GRY!Use this to remove shaders!RST!
echo Much easier to use compared to Auto/Manual. !GRY!^|!RST!
echo !GRY!V!RST!
echo !WHT![H] I need Help [A] About [S] Matject Settings !GRN:9=4![R] Shader Removal/Tools!RST!
) else (
echo Draco for Windows but not really.
echo Much easier to use compared to Auto/Manual.
echo.
echo !WHT![H] I need Help [A] About [S] Matject Settings [R] Shader Removal/Tools!RST!
)
echo.
echo !RED![B] Exit!RST!
echo.
echo !YLW!Press corresponding key to confirm your choice. !GRY!Press Q to know what each action does.!RST!
echo.
choice /c 123hasrbq /n >nul
goto option!errorlevel!
:: OTHER OPTIONS
:option9
call "modules\help" main-screen
title %title%
goto :INTRODUCTION
:option8
exit 0
:option7
cls
echo !RED!^< [B] Back to main screen!RST!
::echo !RED!^< [B] Back !RST!^| !WHT!Home -^> Tools!RST!
echo.
echo [1] Shader Removal / Restore default materials
echo [2] Open Minecraft app folder
echo [3] Open Minecraft data folder
echo.
echo !GRN![4] View Matject on GitHub :^)
echo !WHT![5] Visit jq website
echo [6] View material-updater on mcbegamerxx954's GitHub