Skip to content

Commit 2b74710

Browse files
author
ozelot379
committed
Most ui conversions are now experimental and need to enabled (if you want to try)
1 parent 8fa2189 commit 2b74710

21 files changed

Lines changed: 227 additions & 47 deletions

‎.github/ISSUE_TEMPLATE/issue.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ assignees: ''
1111
A clear and concise description of what the issue is.
1212

1313
**Context**
14-
WebApp or CLI?
14+
Web app or CLI?
1515

1616
**System info**
1717
System OS:
18-
Browser (If WebApp):
18+
Browser (If web app):
1919
NodeJS (If CLI):
2020

2121
**Texture pack**

‎CHANGELOG.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Changelog
22

33
## [x]
4-
- Convert dialog, inventory and recipe book ui
4+
- Most ui conversions are now experimental and need to enabled (if you want to try)
5+
- Convert dialog and inventory ui (Experimental)
56
- Improve error handling
67
- Possible bugs fixed in:
78
- Fix crosshair

‎README.md‎

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,31 @@ THIS PROJECT IS NO OFFICIAL MINECRAFT] PRODUCT - NOT AUTHORIZED OR ASSOCIATED BY
33
---
44

55
# Convert Minecraft Java texture packs to Bedrock texture packs
6-
7-
Look at https://ozelot379.github.io/ConvertJavaTextureToBedrock
8-
9-
It works directly in your browser
10-
11-
It supports currently the follow Minecraft versions:
6+
It supports the follow Minecraft versions:
127

138
| Minecraft | Version |
149
|-----------|---------|
1510
| Java | v1.13.x, v1.14.x or v1.15.x |
1611
| Bedrock | v1.14.x |
1712

18-
Currently it supports to convert blocks, items, entities, paintings, particles, map icons, mob effects and some basic ui textures
19-
2013
Some conversions of HD texture packs may takes a while
2114

2215
This project is inspired by the no longer continued [PCTexture2PE](https://github.com/rodrigojxd/PCTexture2PE)
2316

17+
It supports to convert blocks, items, entities, paintings, particles, map icons, mob effects and some more basic ui textures (hotbar)
18+
19+
Some features are disabled by default, but can be enabled if you want to try:
20+
- UI
21+
- Buttons
22+
- Tabs
23+
- Dialogs
24+
- Inventory
25+
26+
## Web app
27+
Look at https://ozelot379.github.io/ConvertJavaTextureToBedrock
28+
29+
It works directly in your browser
30+
2431
## CLI
2532
As an alternative you can also use the cli version
2633

@@ -43,10 +50,10 @@ ConvertJavaTextureToBedrock -i input/java_texture_pack.zip -o output/bedrock_tex
4350
| -i (Required) | Input folder or zip path |
4451
| -o (Required) | Output folder or zip path |
4552
| -l | Show log (Default `true`) |
53+
| -e | Experimental features (Default `false`) |
4654

47-
## Known issues
48-
- Convert horse textures is very tricky and may buggy
49-
- Convert weather textures (rain and snow) may not works (seems to be an other format as the default)
55+
## Report issue
56+
Use github repo issues (https://github.com/ozelot379/ConvertJavaTextureToBedrock/issues/new/choose)
5057

5158
# Extras (for texture pack creators)
5259

@@ -72,7 +79,7 @@ Then install the dependencies
7279
yarn
7380
```
7481

75-
## WebApp
82+
## Web app
7683
```bash
7784
NODE_ENV=development yarn debug:webapp
7885
```
@@ -113,7 +120,7 @@ You can now convert your texture packs
113120
```javascript
114121
let output;
115122
try {
116-
output = await new ConvertJavaTextureToBedrock(input, output, log).convert();
123+
output = await new ConvertJavaTextureToBedrock(input, output, log, options).convert();
117124
} catch (err) {
118125

119126
}
@@ -154,6 +161,11 @@ try {
154161
| `SlientLog` | Disable log |
155162
| `AbstractLog` | Base log |
156163

164+
## Options
165+
| Key | Description |
166+
|-----|-------------|
167+
| `experimental` | Experimental features |
168+
157169
## Example
158170
```javascript
159171
import ConvertJavaTextureToBedrock, {ConsoleLog, Input, LocalFileInputEntry, LocalFileOutput} from "@ozelot379/convert-minecraft-java-texture-to-bedrock";

‎src/Options.js‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* Class Options
3+
*/
4+
class Options {
5+
constructor() {
6+
/**
7+
* @type {boolean}
8+
*/
9+
this.experimental = false;
10+
}
11+
}
12+
13+
export {Options};

‎src/cli.js‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ import yargs from "yargs";
3131
default: true,
3232
describe: "Log",
3333
type: "boolean"
34+
},
35+
e: {
36+
alias: "experimental",
37+
default: false,
38+
describe: "Experimental features",
39+
type: "boolean"
3440
}
3541
})
3642
.help("help").alias("h", "help")
@@ -41,7 +47,10 @@ import yargs from "yargs";
4147
return new ConvertJavaTextureToBedrock(
4248
new Input(fs.statSync(argv.input).isDirectory() ? new LocalFolderInputEntry(argv.input) : new LocalFileInputEntry(argv.input)),
4349
(argv.output.includes(".") ? new LocalFileOutput(argv.output) : new LocalFolderOutput(argv.output)),
44-
(argv.log ? new ConsoleLog() : new SilentLog())
50+
(argv.log ? new ConsoleLog() : new SilentLog()),
51+
{
52+
experimental: argv.experimental
53+
}
4554
).convert();
4655
} catch (err) {
4756
console.error(err.message);

‎src/converter/AbstractConverter.js‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {AbstractInput} from "./../input"
22
import {AbstractLog} from "./../log";
33
import {AbstractOutput} from "./../output";
44
import Jimp from "@ozelot379/jimp-plugins";
5+
import {Options} from "./../Options";
56

67
/**
78
* Class AbstractConverter
@@ -63,6 +64,12 @@ class AbstractConverter {
6364
* @protected
6465
*/
6566
this.log;
67+
/**
68+
* @type {Object}
69+
*
70+
* @protected
71+
*/
72+
this.options;
6673
/**
6774
* @type {*}
6875
*
@@ -75,13 +82,15 @@ class AbstractConverter {
7582
* @param {AbstractInput} input
7683
* @param {AbstractOutput} output
7784
* @param {AbstractLog} log
85+
* @param {Options} options
7886
*
7987
* @returns Promise<>
8088
*/
81-
async _init(input, output, log) {
89+
async _init(input, output, log, options) {
8290
this.input = input;
8391
this.output = output;
8492
this.log = log;
93+
this.options = options;
8594
}
8695

8796
/**

‎src/converter/DespriteConverter.js‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ class DespriteConverter extends AbstractConverter {
5858
[141, 0, 20, 22, "textures/ui/hotbar_7.png"],
5959
[161, 0, 20, 22, "textures/ui/hotbar_8.png"],
6060
[181, 0, 1, 22, "textures/ui/hotbar_end_cap.png"],
61-
[0, 22, 24, 24, "textures/ui/pocket_ui_highlight_selected_slot.png"],
62-
[0, 22, 24, 24, "textures/ui/pocket_ui_highlight_slot.png"],
6361
[0, 22, 24, 24, "textures/ui/selected_hotbar_slot.png"]
6462
]
6563
],
@@ -73,20 +71,10 @@ class DespriteConverter extends AbstractConverter {
7371
[0, 166, 66, 66, "textures/ui/cartography_table_glass.png"]
7472
]
7573
],
76-
[
77-
"textures/gui/container/horse.png",
78-
256,
79-
[
80-
[1, 221, 16, 16, "textures/ui/empty_horse_slot_armor.png"],
81-
[19, 221, 16, 16, "textures/ui/empty_horse_slot_saddle.png"],
82-
[37, 221, 16, 16, "textures/ui/empty_llama_slot_carpet.png"]
83-
]
84-
],
8574
[
8675
"textures/gui/container/inventory.png",
8776
256,
8877
[
89-
[135, 29, 16, 13, "textures/ui/arrow.png"],
9078
[141, 166, 24, 24, "textures/ui/hud_mob_effect_background.png"]
9179
]
9280
]
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import {AbstractConverter} from "./AbstractConverter";
2+
3+
/**
4+
* Class DespriteExperimentalConverter
5+
*
6+
* @experimental
7+
*/
8+
class DespriteExperimentalConverter extends AbstractConverter {
9+
/**
10+
* @inheritDoc
11+
*/
12+
async convert() {
13+
if (!this.options.experimental) {
14+
return [];
15+
}
16+
17+
const [input, factor_detect, sprites] = this.data;
18+
19+
if (!await this.output.exists(input)) {
20+
return [];
21+
}
22+
23+
const image_from = await this.readImage(input);
24+
25+
image_from.ensureMinWidth(factor_detect);
26+
27+
const factor = (image_from.getWidth() / factor_detect);
28+
29+
for (const [x, y, width, height, to] of sprites) {
30+
this.log.log(`Desprite ${to} (Experimental)`);
31+
32+
const image = image_from.clone().crop((x * factor), (y * factor), (width * factor), (height * factor));
33+
34+
await this.writeImage(to, image);
35+
}
36+
37+
return [];
38+
}
39+
40+
/**
41+
* @inheritDoc
42+
*/
43+
static get DEFAULT_CONVERTER_DATA() {
44+
return [
45+
[
46+
"textures/gui/widgets.png",
47+
256,
48+
[
49+
[0, 22, 24, 24, "textures/ui/pocket_ui_highlight_selected_slot.png"],
50+
[0, 22, 24, 24, "textures/ui/pocket_ui_highlight_slot.png"]
51+
]
52+
],
53+
[
54+
"textures/gui/container/horse.png",
55+
256,
56+
[
57+
[1, 221, 16, 16, "textures/ui/empty_horse_slot_armor.png"],
58+
[19, 221, 16, 16, "textures/ui/empty_horse_slot_saddle.png"],
59+
[37, 221, 16, 16, "textures/ui/empty_llama_slot_carpet.png"]
60+
]
61+
],
62+
[
63+
"textures/gui/container/inventory.png",
64+
256,
65+
[
66+
[135, 29, 16, 13, "textures/ui/arrow.png"]
67+
]
68+
]
69+
];
70+
}
71+
}
72+
73+
export {DespriteExperimentalConverter};

‎src/converter/DialogConverter.js‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@ import {AbstractConverter} from "./AbstractConverter";
22

33
/**
44
* Class DialogConverter
5+
*
6+
* @experimental
57
*/
68
class DialogConverter extends AbstractConverter {
79
/**
810
* @inheritDoc
911
*/
1012
async convert() {
13+
if (!this.options.experimental) {
14+
return [];
15+
}
16+
1117
const [from, factor_detect, dialogs] = this.data;
1218

1319
if (!await this.output.exists(from)) {
@@ -48,7 +54,7 @@ class DialogConverter extends AbstractConverter {
4854
};
4955

5056
const to_png = to + ".png";
51-
this.log.log(`Convert dialog ${to_png}`);
57+
this.log.log(`Convert dialog ${to_png} (Experimental)`);
5258
await this.writeImage(to_png, to_image);
5359

5460
await this.writeJson(to + ".json", metadata);

‎src/converter/IconsConverter.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class IconsConverter extends AbstractConverter {
2020

2121
image.scan(0, 0, image.getWidth(), image.getHeight(), (x, y, idx) => {
2222
if (image.bitmap.data[idx + 3] === 0) {
23+
// (255 values)
2324
image.bitmap.data[idx] = 0;
2425
image.bitmap.data[idx + 1] = 0;
2526
image.bitmap.data[idx + 2] = 0;

0 commit comments

Comments
 (0)