forked from rtm516/ConvertJavaTextureToBedrock
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Convert illager banner - Fixed bugs due previous version
- Loading branch information
ozelot379
committed
Jul 7, 2019
1 parent
c8bbff0
commit 0ab84fa
Showing
10 changed files
with
202 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import AbstractConverter from "./AbstractConverter"; | ||
import fs from "fs-extra"; | ||
import Jimp from "jimp"; | ||
import Utils from "../Utils/Utils"; | ||
|
||
/** | ||
* Class BannerPatternConverter | ||
*/ | ||
class BannerPatternConverter extends AbstractConverter { | ||
/** | ||
* @inheritDoc | ||
*/ | ||
async convert() { | ||
for await (const [base, patterns, to] of this.getData()) { | ||
const base_path = Utils.fromPath(base, this.path); | ||
const to_path = Utils.toPath(to, base_path, this.path); | ||
|
||
if (fs.existsSync(base_path)) { | ||
let image = null; | ||
|
||
for (const [pattern, color] of patterns) { | ||
const pattern_path = Utils.fromPath(pattern, this.path); | ||
|
||
if (fs.existsSync(pattern_path)) { | ||
const image_pattern = await Jimp.read(pattern_path); | ||
|
||
if (image === null) { | ||
Utils.log(`Convert pattern banner ${to}`); | ||
|
||
image = await Jimp.read(base_path); | ||
|
||
const factor = (image.getWidth() / 64); | ||
|
||
image.composite(image.clone().crop((44 * factor), 0, (8 * factor), (44 * factor)), (52 * factor), 0); | ||
image.composite(image.clone().crop((44 * factor), (5 * factor), (8 * factor), (20 * factor)), (52 * factor), (44 * factor)); | ||
} | ||
|
||
image_pattern.scan(0, 0, image_pattern.getWidth(), image_pattern.getHeight(), (x, y, idx) => { | ||
if (image_pattern.bitmap.data[idx] > 0 && image_pattern.bitmap.data[idx + 3] === 255) { | ||
image.bitmap.data[idx] = color[0]; | ||
image.bitmap.data[idx + 1] = color[1]; | ||
image.bitmap.data[idx + 2] = color[2]; | ||
} | ||
}); | ||
} | ||
|
||
if (image !== null) { | ||
await image.writeAsync(to_path); | ||
} | ||
} | ||
} | ||
} | ||
|
||
return []; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
async* getData() { | ||
const data = [ | ||
["textures/entity/banner_base.png", [ | ||
// https://www.planetminecraft.com/banner/pillager-banner-199281/ | ||
["textures/entity/banner/base.png", [255, 255, 255]], | ||
["textures/entity/banner/rhombus.png", [0, 190, 190]], | ||
["textures/entity/banner/stripe_bottom.png", [190, 190, 190]], | ||
["textures/entity/banner/stripe_center.png", [63, 63, 63]], | ||
["textures/entity/banner/stripe_middle.png", [0, 0, 0]], | ||
["textures/entity/banner/half_horizontal.png", [190, 190, 190]], | ||
["textures/entity/banner/circle.png", [190, 190, 190]], | ||
["textures/entity/banner/border.png", [0, 0, 0]] | ||
], "textures/entity/banner/banner_pattern_illager.png"] | ||
]; | ||
|
||
for (const date of data) { | ||
yield date; | ||
} | ||
} | ||
} | ||
|
||
export default BannerPatternConverter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import AbstractConverter from "./AbstractConverter"; | ||
import DeleteConverter from "./DeleteConverter"; | ||
import fs from "fs-extra"; | ||
import Jimp from "jimp"; | ||
import Utils from "../Utils/Utils"; | ||
|
||
/** | ||
* Class WeatherConverter | ||
*/ | ||
class WeatherConverter extends AbstractConverter { | ||
/** | ||
* @inheritDoc | ||
*/ | ||
async convert() { | ||
const to_delete = []; | ||
|
||
for await (const [snow, rain, to] of this.getData()) { | ||
const snow_path = Utils.fromPath(snow, this.path); | ||
const rain_path = Utils.toPath(rain, snow_path, this.path); | ||
const to_path = Utils.toPath(to, snow_path, this.path); | ||
|
||
if (fs.existsSync(snow_path) && fs.existsSync(rain_path)) { | ||
Utils.log(`Convert weather`); | ||
|
||
const snow_image = await Jimp.read(snow_path); | ||
|
||
const rain_image = await Jimp.read(rain_path); | ||
|
||
const factor = (snow_image.getWidth() / 64); | ||
|
||
const image = await Jimp.create((32 * factor), (32 * factor)); | ||
|
||
// Snow | ||
image.composite(snow_image.clone().crop((55 * factor), (15 * factor), (3 * factor), (3 * factor)), 0, 0); | ||
image.composite(snow_image.clone().crop((42 * factor), 0, (3 * factor), (3 * factor)), (4 * factor), 0); | ||
image.composite(snow_image.clone().crop((36 * factor), (14 * factor), (3 * factor), (3 * factor)), (8 * factor), 0); | ||
|
||
image.composite(snow_image.clone().crop((55 * factor), (15 * factor), (3 * factor), (3 * factor)), (12 * factor), 0); | ||
image.composite(snow_image.clone().crop((42 * factor), 0, (3 * factor), (3 * factor)), (16 * factor), 0); | ||
image.composite(snow_image.clone().crop((36 * factor), (14 * factor), (3 * factor), (3 * factor)), (20 * factor), 0); | ||
|
||
image.composite(snow_image.clone().crop((55 * factor), (15 * factor), (3 * factor), (3 * factor)), (24 * factor), 0); | ||
image.composite(snow_image.clone().crop((42 * factor), 0, (3 * factor), (3 * factor)), (28 * factor), 0); | ||
|
||
to_delete.push(snow); | ||
|
||
// Rain | ||
image.composite(rain_image.clone().crop((3 * factor), 0, factor, (20 * factor)), factor, (5 * factor)); | ||
|
||
image.composite(rain_image.clone().crop((22 * factor), 0, factor, (3 * factor)), (5 * factor), (6 * factor)); | ||
image.composite(rain_image.clone().crop(0, (7 * factor), factor, (5 * factor)), (5 * factor), (12 * factor)); | ||
|
||
image.composite(rain_image.clone().crop((59 * factor), (65 * factor), factor, (10 * factor)), (9 * factor), (7 * factor)); | ||
|
||
image.composite(rain_image.clone().crop((12 * factor), (85 * factor), factor, (9 * factor)), (13 * factor), (8 * factor)); | ||
|
||
image.composite(rain_image.clone().crop(0, (23 * factor), factor, factor), (17 * factor), (6 * factor)); | ||
image.composite(rain_image.clone().crop((17 * factor), (168 * factor), factor, (11 * factor)), (17 * factor), (8 * factor)); | ||
|
||
image.composite(rain_image.clone().crop((59 * factor), (65 * factor), factor, (10 * factor)), (21 * factor), (7 * factor)); | ||
|
||
image.composite(rain_image.clone().crop(0, (7 * factor), factor, (5 * factor)), (25 * factor), (9 * factor)); | ||
|
||
image.composite(rain_image.clone().crop((59 * factor), (65 * factor), factor, (10 * factor)), (29 * factor), (5 * factor)); | ||
image.composite(rain_image.clone().crop((10 * factor), (19 * factor), (2 * factor), (2 * factor)), (29 * factor), (18 * factor)); | ||
|
||
to_delete.push(rain); | ||
|
||
await image.writeAsync(to_path); | ||
} | ||
} | ||
|
||
return [[DeleteConverter, to_delete]]; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
async* getData() { | ||
const data = [ | ||
["textures/environment/snow.png", "textures/environment/rain.png", "./weather.png"] | ||
]; | ||
|
||
for (const date of data) { | ||
yield date; | ||
} | ||
} | ||
} | ||
|
||
export default WeatherConverter; |