Skip to content

Commit

Permalink
Merge pull request #7 from agentdid127/master
Browse files Browse the repository at this point in the history
v0.0.2
  • Loading branch information
CoryBorek authored Jan 24, 2022
2 parents b71298f + 23cfad3 commit 64973b3
Show file tree
Hide file tree
Showing 6 changed files with 449 additions and 13 deletions.
4 changes: 2 additions & 2 deletions bedrock-conversion/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

<groupId>com.agentdid127.resourcepack</groupId>
<artifactId>bedrock-conversion</artifactId>
<version>1.0-SNAPSHOT</version>
<version>${parent.version}</version>

<parent>
<artifactId>RPC-Bedrock</artifactId>
<groupId>com.agentdid127.resourcepack</groupId>
<version>0.0.1</version>
<version>0.0.2</version>
</parent>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class NameConverter extends Converter {

protected final Mapping blockMapping = new BlockMapping();
protected final Mapping blockTGAMapping = new BlockTGAMapping();
protected final Mapping itemMapping = new ItemMapping();

public NameConverter(PackConverter packConverter) {
super(packConverter);
Expand All @@ -32,16 +33,113 @@ public void convert(Pack pack) throws IOException {
if (textures_old.toFile().exists())
Util.copyDir(textures_old, textures);

blocks(textures);
items(textures);

Path blocks = textures.resolve("block");



}

private void items(Path textures) throws IOException {
Path items = textures.resolve("items");

if (textures.resolve("item").toFile().exists()) {
Files.move(textures.resolve("item"), items);
renameAll(itemMapping, ".png", items);
}
}

private void blocks(Path textures) throws IOException {
Path blocks = textures.resolve("blocks");

//TODO: Find what images need to be renamed, and rename them

if (blocks.toFile().exists()) {
if (textures.resolve("block").toFile().exists()) {

Files.move(textures.resolve("block"), blocks);
renameAll(blockMapping, ".png", blocks);
renameAll(blockTGAMapping, ".png", ".tga", blocks);

Path candles = blocks.resolve("candles");

if (!candles.toFile().exists()) candles.toFile().mkdir();
moveFile(blocks, candles, "black_candle.png");
moveFile(blocks, candles, "black_candle_lit.png");
moveFile(blocks, candles, "blue_candle.png");
moveFile(blocks, candles, "blue_candle_lit.png");
moveFile(blocks, candles, "brown_candle.png");
moveFile(blocks, candles, "brown_candle_lit.png");
moveFile(blocks, candles, "candle.png");
moveFile(blocks, candles, "candle_lit.png");
moveFile(blocks, candles, "cyan_candle.png");
moveFile(blocks, candles, "cyan_candle_lit.png");
moveFile(blocks, candles, "gray_candle.png");
moveFile(blocks, candles, "gray_candle_lit.png");
moveFile(blocks, candles, "green_candle.png");
moveFile(blocks, candles, "green_candle_lit.png");
moveFile(blocks, candles, "light_blue_candle.png");
moveFile(blocks, candles, "light_blue_candle_lit.png");
moveFile(blocks, candles, "light_gray_candle.png");
moveFile(blocks, candles, "light_gray_candle_lit.png");
moveFile(blocks, candles, "lime_candle.png");
moveFile(blocks, candles, "lime_candle_lit.png");
moveFile(blocks, candles, "magenta_candle.png");
moveFile(blocks, candles, "magenta_candle_lit.png");
moveFile(blocks, candles, "orange_candle.png");
moveFile(blocks, candles, "orange_candle_lit.png");
moveFile(blocks, candles, "pink_candle.png");
moveFile(blocks, candles, "pink_candle_lit.png");
moveFile(blocks, candles, "purple_candle.png");
moveFile(blocks, candles, "purple_candle_lit.png");
moveFile(blocks, candles, "red_candle.png");
moveFile(blocks, candles, "red_candle_lit.png");
moveFile(blocks, candles, "white_candle.png");
moveFile(blocks, candles, "white_candle_lit.png");
moveFile(blocks, candles, "yellow_candle.png");
moveFile(blocks, candles, "yellow_candle_lit.png");

Path deepslate = blocks.resolve("deepslate");
if (!deepslate.toFile().exists()) deepslate.toFile().mkdir();
moveFile(blocks, deepslate, "chiseled_deepslate.png" );
moveFile(blocks, deepslate, "cobbled_deepslate.png" );
moveFile(blocks, deepslate, "cracked_deepslate_bricks.png" );
moveFile(blocks, deepslate, "cracked_deepslate_tiles.png" );
moveFile(blocks, deepslate, "deepslate.png" );
moveFile(blocks, deepslate, "deepslate_bricks.png" );
moveFile(blocks, deepslate, "deepslate_coal_ore.png" );
moveFile(blocks, deepslate, "deepslate_copper_ore.png" );
moveFile(blocks, deepslate, "deepslate_diamond_ore.png" );
moveFile(blocks, deepslate, "deepslate_emerald_ore.png" );
moveFile(blocks, deepslate, "deepslate_gold_ore.png" );
moveFile(blocks, deepslate, "deepslate_iron_ore.png" );
moveFile(blocks, deepslate, "deepslate_lapis_ore.png" );
moveFile(blocks, deepslate, "deepslate_redstone_ore.png" );
moveFile(blocks, deepslate, "deepslate_tiles.png" );
moveFile(blocks, deepslate, "deepslate_top.png" );
moveFile(blocks, deepslate, "polished_deepslate.png" );

Path hugeFungus = blocks.resolve("huge_fungus");
if (!hugeFungus.toFile().exists()) hugeFungus.toFile().mkdir();
moveFile(blocks, hugeFungus, "crimson_door_bottom.png", "crimson_door_lower.png");
moveFile(blocks, hugeFungus, "crimson_door_top.png");
moveFile(blocks, hugeFungus, "crimson_stem.png", "crimson_log_side.png");
moveFile(blocks, hugeFungus, "crimson_stem_top.png", "crimson_log_top.png");
moveFile(blocks, hugeFungus, "crimson_planks.png");
moveFile(blocks, hugeFungus, "crimson_trapdoor.png");
moveFile(blocks, hugeFungus, "stripped_crimson_stem.png", "stripped_crimson_stem_side.png");
moveFile(blocks, hugeFungus, "stripped_crimson_stem_top.png");
moveFile(blocks, hugeFungus, "stripped_warped_stem.png", "stripped_warped_stem_side.png");
moveFile(blocks, hugeFungus, "stripped_warped_stem_top.png");
moveFile(blocks, hugeFungus, "warped_door_bottom.png", "warped_door_lower.png");
moveFile(blocks, hugeFungus, "warped_door_top.png");
moveFile(blocks, hugeFungus, "warped_planks.png");
moveFile(blocks, hugeFungus, "warped_stem.png", "warped_stem_side.png");
moveFile(blocks, hugeFungus, "warped_stem_top.png");
moveFile(blocks, hugeFungus, "warped_trapdoor.png");



Files.move(blocks, textures.resolve("blocks"));
renameAll(blockMapping, ".png", textures.resolve("blocks"));
renameAll(blockTGAMapping, ".png", ".tga", textures.resolve("blocks"));

//grass_block_side_overlay -> grass_side
if (textures.resolve("blocks").resolve("grass_block_side_overlay.png").toFile().exists()) {
Expand All @@ -50,11 +148,21 @@ public void convert(Pack pack) throws IOException {
System.out.println("Grass Conversion: " + grass.storeTGA());
Util.renameFile(textures.resolve("blocks").resolve("grass_block_side_overlay.png"), "grass_side.tga");
}
}
}
}

private void moveFile(Path oldDir, Path newDir, String name) throws IOException {
Path old = oldDir.resolve(name);
Path newF = newDir.resolve(name);

if (old.toFile().exists()) Files.move(old, newF);
}
private void moveFile(Path oldDir, Path newDir, String name, String newName) throws IOException {
Path old = oldDir.resolve(name);
Path newF = newDir.resolve(newName);

if (old.toFile().exists()) Files.move(old, newF);
}


protected void renameAll(Mapping mapping, String extension, String newExtension, Path path) throws IOException {
Expand Down Expand Up @@ -116,10 +224,12 @@ protected void renameAll(Mapping mapping, String extension, Path path) throws IO
else if (!ret) {
packConverter.log(" Failed to Rename: " + path1.getFileName().toString() + "->" + newName + extension);
}

}
});
}


protected abstract static class Mapping {

protected final Map<String, String> mapping = new HashMap<>();
Expand Down Expand Up @@ -163,6 +273,19 @@ protected void load() {
}
}
}

protected class ItemMapping extends Mapping {

@Override
protected void load() {
JsonObject blocks = Util.readJsonResource(packConverter.getGson(), "/items.json").getAsJsonObject("items");
if (blocks != null) {
for (Map.Entry<String, JsonElement> entry : blocks.entrySet()) {
this.mapping.put(entry.getKey(), entry.getValue().getAsString());
}
}
}
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void convert(Pack pack) throws IOException {
JsonObject header = new JsonObject();
//header properties
header.addProperty("description", json.get("pack").getAsJsonObject().get("description").getAsString());
header.addProperty("name", "Converted Pack");
header.addProperty("name", pack.getFileName());
header.addProperty("uuid", UUID.randomUUID().toString());

//version
Expand Down
Loading

0 comments on commit 64973b3

Please sign in to comment.