Skip to content

Commit

Permalink
fix: enable trim-datapack manually
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy0000 committed May 16, 2024
1 parent 412fc1b commit b59d70c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ private static String modelPathToPackPath(String modelPath) {
private final boolean extractLang = !new File(packFolder, "lang").exists();
private final boolean extractTextures = !new File(packFolder, "textures").exists();
private final boolean extractSounds = !new File(packFolder, "sounds").exists();

private void extractDefaultFolders() {
final ZipInputStream zip = ResourcesManager.browse();
try {
Expand Down Expand Up @@ -535,7 +536,8 @@ private void readFileToVirtuals(final Collection<VirtualFile> output, File file,
try {
final InputStream fis;
if (file.getName().endsWith(".json")) fis = processJsonFile(file);
else if (CustomArmorType.getSetting() == CustomArmorType.SHADER && shaderArmorTextures.registerImage(file)) return;
else if (CustomArmorType.getSetting() == CustomArmorType.SHADER && shaderArmorTextures.registerImage(file))
return;
else fis = new FileInputStream(file);

output.add(new VirtualFile(getZipFilePath(file.getParentFile().getCanonicalPath(), newFolder), file.getName(), fis));
Expand Down Expand Up @@ -598,18 +600,23 @@ private void handleCustomArmor(List<VirtualFile> output) {
switch (customArmorType) {
case TRIMS -> trimArmorDatapack.generateTrimAssets(output);
case SHADER -> {
if (Settings.CUSTOM_ARMOR_SHADER_GENERATE_CUSTOM_TEXTURES.toBool() && shaderArmorTextures.hasCustomArmors()) try {
String armorPath = "assets/minecraft/textures/models/armor";
output.add(new VirtualFile(armorPath, "leather_layer_1.png", shaderArmorTextures.getLayerOne()));
output.add(new VirtualFile(armorPath, "leather_layer_2.png", shaderArmorTextures.getLayerTwo()));
if (Settings.CUSTOM_ARMOR_SHADER_GENERATE_SHADER_COMPATIBLE_ARMOR.toBool()) {
output.addAll(shaderArmorTextures.getOptifineFiles());
if (Settings.CUSTOM_ARMOR_SHADER_GENERATE_CUSTOM_TEXTURES.toBool() && shaderArmorTextures.hasCustomArmors())
try {
String armorPath = "assets/minecraft/textures/models/armor";
output.add(new VirtualFile(armorPath, "leather_layer_1.png", shaderArmorTextures.getLayerOne()));
output.add(new VirtualFile(armorPath, "leather_layer_2.png", shaderArmorTextures.getLayerTwo()));
if (Settings.CUSTOM_ARMOR_SHADER_GENERATE_SHADER_COMPATIBLE_ARMOR.toBool()) {
output.addAll(shaderArmorTextures.getOptifineFiles());
}
} catch (IOException e) {
e.printStackTrace();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
if (VersionUtil.isPaperServer()) {
Bukkit.getDatapackManager().getPacks().stream().filter(d -> d.getName().equals(TrimArmorDatapack.datapackKey.value()))
.findFirst().ifPresent(d -> d.setEnabled(CustomArmorType.getSetting() == CustomArmorType.TRIMS));
}
}

private void convertGlobalLang(List<VirtualFile> output) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,12 @@
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;

public class TrimArmorDatapack {
private static final World defaultWorld = Bukkit.getWorlds().get(0);
private static final Key datapackKey = Key.key("minecraft:file/oraxen_custom_armor");
public static final Key datapackKey = Key.key("minecraft:file/oraxen_custom_armor");
private static final File customArmorDatapack = defaultWorld.getWorldFolder().toPath().resolve("datapacks/oraxen_custom_armor").toFile();
private final boolean isFirstInstall;
private final boolean datapackEnabled;
Expand Down

0 comments on commit b59d70c

Please sign in to comment.