Skip to content

Commit

Permalink
Update script.js
Browse files Browse the repository at this point in the history
  • Loading branch information
PepeOnGithub authored Aug 13, 2024
1 parent 1f29318 commit 83094fb
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions script.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
document.getElementById('fileInput')
.addEventListener('change', function() {
document.getElementById('fileInput').addEventListener('change', function() {
const outputDiv = document.getElementById('output');
const fileInput = document.getElementById('fileInput');

Expand Down Expand Up @@ -55,7 +54,9 @@ async function convertPack() {
const file = contents.files[fileName];

if (!file.dir) {
if (fileName.includes("assets/minecraft/textures/entity/") || fileName.includes("assets/minecraft/textures/gui/") || fileName.includes("assets/minecraft/textures/font/")) {
if (fileName.includes("assets/minecraft/textures/entity/") ||
fileName.includes("assets/minecraft/textures/gui/") ||
fileName.includes("assets/minecraft/textures/font/")) {
continue;
}

Expand All @@ -81,8 +82,7 @@ async function convertPack() {
}
}

newFileName = newFileName.replace("/block/", "/blocks/")
.replace("/item/", "/items/");
newFileName = newFileName.replace("/block/", "/blocks/").replace("/item/", "/items/");

const data = await file.async("blob");
bedrockZip.file(newFileName, data);
Expand All @@ -98,16 +98,13 @@ async function convertPack() {
bedrockZip.file("manifest.json", JSON.stringify(manifest, null, 4));
console.log("manifest.json file created.");

const blob = await bedrockZip.generateAsync({
type: "blob"
});
const blob = await bedrockZip.generateAsync({ type: "blob" });
const endTime = performance.now();
const duration = ((endTime - startTime) / 1000)
.toFixed(2);

const duration = ((endTime - startTime) / 1000).toFixed(2);

const newFileName = file.name.replace('.zip', ' [Converted].zip');
saveAs(blob, newFileName);

updateOutput(`Conversion complete! Your download should start shortly. Time taken: ${duration} seconds.`);
console.log(`Conversion complete! Time taken: ${duration} seconds.`);
} catch (error) {
Expand All @@ -133,11 +130,13 @@ function generateManifest(name, description) {
"version": [1, 0, 0],
"min_engine_version": [1, 20, 0]
},
"modules": [{
"type": "resources",
"uuid": generateUUID(),
"version": [1, 0, 0]
}]
"modules": [
{
"type": "resources",
"uuid": generateUUID(),
"version": [1, 0, 0]
}
]
};
}

Expand Down

0 comments on commit 83094fb

Please sign in to comment.