Skip to content

Commit

Permalink
- Convert weather environment
Browse files Browse the repository at this point in the history
- Convert illager banner
- Fixed bugs due previous version
  • Loading branch information
ozelot379 committed Jul 7, 2019
1 parent c8bbff0 commit 0ab84fa
Show file tree
Hide file tree
Showing 10 changed files with 202 additions and 21 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## [1.3.0]
- Convert weather environment
- Convert illager banner
- Fixed bugs due previous version

## [1.2.0]
- Convert paintings, particles, map icons and banners

Expand Down
22 changes: 11 additions & 11 deletions dist/cli.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@ozelot379/convert-minecraft-java-texture-to-bedrock",
"productName": "ConvertMinecraftJavaTextureToBedrock",
"version": "1.2.0",
"version": "1.3.0",
"description": "Convert Minecraft Java texture packs to Minecraft Bedrock texture packs",
"keywords": [
"Minecraft",
Expand Down
81 changes: 81 additions & 0 deletions src/Converter/BannerPatternConverter.js
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;
4 changes: 4 additions & 0 deletions src/Converter/ConvertFactory.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import AbstractConverter from "./AbstractConverter";
import AbstractInput from "../Input/AbstractInput";
import AtlasConverter from "./AtlasConverter";
import BannerPatternConverter from "./BannerPatternConverter";
import BedConverter from "./BedConverter";
import ChestFrontConverter from "./ChestFrontConverter";
import ChestSideConverter from "./ChestSideConverter";
Expand All @@ -24,6 +25,7 @@ import SheepConverter from "./SheepConverter";
import SideRotateConverter from "./SideRotateConverter";
import SpriteConverter from "./SpriteConverter";
import VillagerConverter from "./VillagerConverter";
import WeatherConverter from "./WeatherConverter";

/**
* @param {string} temp
Expand Down Expand Up @@ -57,6 +59,7 @@ const converters = [
[MetadataConverter, []],
[RenameConverter, []],
[AtlasConverter, []],
[BannerPatternConverter, []],
[BedConverter, []],
[ChestFrontConverter, []],
[ChestSideConverter, []],
Expand All @@ -68,6 +71,7 @@ const converters = [
[RedstoneDustConverter, []],
[SheepConverter, []],
[VillagerConverter, []],
[WeatherConverter, []],
[OpaqueConverter, []],
[OverlayToTranslateConverter, []],
[ColorizeOverlayConverter, []],
Expand Down
12 changes: 6 additions & 6 deletions src/Converter/CopyConverter.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ class CopyConverter extends AbstractConverter {
["textures/blocks/grass_side_carried.png", "textures/ui/icon_recipe_nature.png"],
["textures/items/bed_red.png", "textures/ui/icon_recipe_item.png"],
["textures/items/diamond_sword.png", "textures/ui/icon_recipe_equipment.png"],
["textures/gui/background/panorama_0.png", ".textures/ui/panorama_0.png"],
["textures/gui/background/panorama_1.png", ".textures/ui/panorama_1.png"],
["textures/gui/background/panorama_2.png", ".textures/ui/panorama_2.png"],
["textures/gui/background/panorama_3.png", ".textures/ui/panorama_3.png"],
["textures/gui/background/panorama_4.png", ".textures/ui/panorama_4.png"],
["textures/gui/background/panorama_5.png", ".textures/ui/panorama_5.png"],
["textures/gui/background/panorama_0.png", "textures/ui/panorama_0.png"],
["textures/gui/background/panorama_1.png", "textures/ui/panorama_1.png"],
["textures/gui/background/panorama_2.png", "textures/ui/panorama_2.png"],
["textures/gui/background/panorama_3.png", "textures/ui/panorama_3.png"],
["textures/gui/background/panorama_4.png", "textures/ui/panorama_4.png"],
["textures/gui/background/panorama_5.png", "textures/ui/panorama_5.png"],

["bedrock_textures", "./textures"]
];
Expand Down
1 change: 1 addition & 0 deletions src/Converter/PngToTgaConverter.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ class PngToTgaConverter extends AbstractConverter {
["textures/entity/zombie_villager2/professions/stonemason.png", "./stonemason.tga"],
["textures/entity/zombie_villager2/professions/toolsmith.png", "./toolsmith.tga"],
["textures/entity/zombie_villager2/professions/weaponsmith.png", "./weaponsmith.tga"],
["textures/gui/background/panorama_overlay.png", "textures/ui/panorama_overlay.tga"],
["textures/items/fireworks_charge.png", "./fireworks_charge.tga"],
["textures/items/leather_boots.png", "./leather_boots.tga"],
["textures/items/leather_helmet.png", "./leather_helmet.tga"],
Expand Down
2 changes: 1 addition & 1 deletion src/Converter/RenameConverter.js
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,7 @@ class RenameConverter extends AbstractConverter {

// UI
["textures/gui/options_background.png", "./background.png"],
["textures/gui/title/background.png", ".textures/gui/background"],
["textures/gui/title/background", "textures/gui/background"],

// Villager
["textures/entity/villager", "./villager2"],
Expand Down
90 changes: 90 additions & 0 deletions src/Converter/WeatherConverter.js
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;

0 comments on commit 0ab84fa

Please sign in to comment.