Skip to content

Commit

Permalink
File separator instead of backslash and slash
Browse files Browse the repository at this point in the history
  • Loading branch information
Plancke committed Jul 26, 2018
1 parent 7057a78 commit cbf1b83
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import net.hypixel.resourcepack.Converter;
import net.hypixel.resourcepack.pack.Pack;
import net.hypixel.resourcepack.PackConverter;
import net.hypixel.resourcepack.Util;
import net.hypixel.resourcepack.pack.Pack;

import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
Expand All @@ -17,8 +18,8 @@ public class AnimationConverter extends Converter {

@Override
public void convert(PackConverter main, Pack pack) throws IOException {
fixAnimations(pack.getWorkingPath().resolve("assets\\minecraft\\textures\\block"));
fixAnimations(pack.getWorkingPath().resolve("assets\\minecraft\\textures\\item"));
fixAnimations(pack.getWorkingPath().resolve("assets" + File.separator + "minecraft" + File.separator + "textures" + File.separator + "block"));
fixAnimations(pack.getWorkingPath().resolve("assets" + File.separator + "minecraft" + File.separator + "textures" + File.separator + "item"));
}

protected void fixAnimations(Path animations) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import net.hypixel.resourcepack.Converter;
import net.hypixel.resourcepack.pack.Pack;
import net.hypixel.resourcepack.PackConverter;
import net.hypixel.resourcepack.Util;
import net.hypixel.resourcepack.pack.Pack;

import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
Expand All @@ -19,7 +20,7 @@ public class BlockStateConverter extends Converter {

@Override
public void convert(PackConverter main, Pack pack) throws IOException {
Path states = pack.getWorkingPath().resolve("assets\\minecraft\\blockstates");
Path states = pack.getWorkingPath().resolve("assets" + File.separator + "minecraft" + File.separator + "blockstates");
if (!states.toFile().exists()) return;

Files.list(states)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package net.hypixel.resourcepack.impl;

import net.hypixel.resourcepack.Converter;
import net.hypixel.resourcepack.pack.Pack;
import net.hypixel.resourcepack.PackConverter;
import net.hypixel.resourcepack.Util;
import net.hypixel.resourcepack.pack.Pack;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.util.HashMap;
Expand All @@ -32,7 +33,7 @@ public MapIconConverter() {

@Override
public void convert(PackConverter main, Pack pack) throws IOException {
Path imagePath = pack.getWorkingPath().resolve("assets/minecraft/textures/map/map_icons.png");
Path imagePath = pack.getWorkingPath().resolve("assets" + File.separator + "minecraft" + File.separator + "textures" + File.separator + "map" + File.separator + "map_icons.png");
if (!imagePath.toFile().exists()) return;

BufferedImage newImage = Util.readImageResource("/map_icons.png");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import net.hypixel.resourcepack.Converter;
import net.hypixel.resourcepack.pack.Pack;
import net.hypixel.resourcepack.PackConverter;
import net.hypixel.resourcepack.Util;
import net.hypixel.resourcepack.pack.Pack;

import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
Expand All @@ -18,7 +19,7 @@ public class ModelConverter extends Converter {

@Override
public void convert(PackConverter main, Pack pack) throws IOException {
Path models = pack.getWorkingPath().resolve("assets\\minecraft\\models");
Path models = pack.getWorkingPath().resolve("assets" + File.separator + "minecraft" + File.separator + "models");

remapModelJson(main, models.resolve("block"));
remapModelJson(main, models.resolve("item"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import net.hypixel.resourcepack.Converter;
import net.hypixel.resourcepack.pack.Pack;
import net.hypixel.resourcepack.PackConverter;
import net.hypixel.resourcepack.Util;
import net.hypixel.resourcepack.pack.Pack;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
Expand All @@ -20,16 +21,16 @@ public class NameConverter extends Converter {

@Override
public void convert(PackConverter main, Pack pack) throws IOException {
Path models = pack.getWorkingPath().resolve("assets\\minecraft\\models");
Path models = pack.getWorkingPath().resolve("assets" + File.separator + "minecraft" + File.separator + "models");
if (models.resolve("blocks").toFile().exists()) Files.move(models.resolve("blocks"), models.resolve("block"));
renameAll(blockMapping, ".json", models.resolve("block"));
if (models.resolve("items").toFile().exists()) Files.move(models.resolve("items"), models.resolve("item"));
renameAll(itemMapping, ".json", models.resolve("item"));

Path blockStates = pack.getWorkingPath().resolve("assets\\minecraft\\blockstates");
Path blockStates = pack.getWorkingPath().resolve("assets" + File.separator + "minecraft" + File.separator + "blockstates");
renameAll(itemMapping, ".json", blockStates);

Path textures = pack.getWorkingPath().resolve("assets\\minecraft\\textures");
Path textures = pack.getWorkingPath().resolve("assets" + File.separator + "minecraft" + File.separator + "textures");
if (textures.resolve("blocks").toFile().exists()) Files.move(textures.resolve("blocks"), textures.resolve("block"));
renameAll(blockMapping, ".png", textures.resolve("block"));
renameAll(blockMapping, ".png.mcmeta", textures.resolve("block"));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
package net.hypixel.resourcepack.impl;

import net.hypixel.resourcepack.Converter;
import net.hypixel.resourcepack.pack.Pack;
import net.hypixel.resourcepack.PackConverter;
import net.hypixel.resourcepack.pack.Pack;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;

public class ParticleConverter extends Converter {

@Override
public void convert(PackConverter main, Pack pack) throws IOException {
Path imagePath = pack.getWorkingPath().resolve("assets/minecraft/textures/particle/particles.png");
Path imagePath = pack.getWorkingPath().resolve("assets" + File.separator + "minecraft" + File.separator + "textures" + File.separator + "particle" + File.separator + "particles.png");
if (!imagePath.toFile().exists()) return;

BufferedImage image = ImageIO.read(imagePath.toFile());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import net.hypixel.resourcepack.Converter;
import net.hypixel.resourcepack.pack.Pack;
import net.hypixel.resourcepack.PackConverter;
import net.hypixel.resourcepack.Util;
import net.hypixel.resourcepack.pack.Pack;

import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
Expand All @@ -19,7 +20,7 @@ public class SoundsConverter extends Converter {

@Override
public void convert(PackConverter main, Pack pack) throws IOException {
Path soundsJsonPath = pack.getWorkingPath().resolve("assets/minecraft/sounds.json");
Path soundsJsonPath = pack.getWorkingPath().resolve("assets" + File.separator + "minecraft" + File.separator + "sounds.json");
if (!soundsJsonPath.toFile().exists()) return;

JsonObject sounds = Util.readJson(soundsJsonPath);
Expand All @@ -35,7 +36,7 @@ public void convert(PackConverter main, Pack pack) throws IOException {
for (JsonElement jsonElement : soundsArray) {
String sound;

Path baseSoundsPath = pack.getWorkingPath().resolve("assets/minecraft/sounds/");
Path baseSoundsPath = pack.getWorkingPath().resolve("assets" + File.separator + "minecraft" + File.separator + "sounds");
Path path = baseSoundsPath.resolve(jsonElement.getAsString() + ".ogg");
if (!Util.fileExistsCorrectCasing(path)) {
String rewrite = path.toFile().getCanonicalPath().substring(baseSoundsPath.toString().length() + 1, path.toFile().getCanonicalPath().length() - 4);
Expand Down

0 comments on commit cbf1b83

Please sign in to comment.