aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java10
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/updater/UpdateLoader.java20
2 files changed, 21 insertions, 9 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
index cd0d08b5..fddb56d6 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
@@ -672,7 +672,8 @@ public class NEUManager {
ea = ea.getCompoundTag("Properties");
ea = ea.getTagList("textures", 10).getCompoundTagAt(0);
String name = ea3.getString("Name").replaceAll(" M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$", "");
- return "put(\"ID\", Utils.createSkull(EnumChatFormatting.AQUA + \"" + name + "\" ,\"" + ea2.getString("Id") + "\", \"" + ea.getString("Value") +"\"));";
+ return "put(\"ID\", Utils.createSkull(EnumChatFormatting.AQUA + \"" + name + "\" ,\"" + ea2.getString("Id") +
+ "\", \"" + ea.getString("Value") + "\"));";
}
}
return null;
@@ -912,6 +913,7 @@ public class NEUManager {
NBTTagCompound tag = stack.getTagCompound();
return getSkullValueFromNBT(tag);
}
+
public String getInternalNameForItem(ItemStack stack) {
if (stack == null) return null;
NBTTagCompound tag = stack.getTagCompound();
@@ -948,8 +950,7 @@ public class NEUManager {
if (!usagesMap.containsKey(internalName)) return false;
List<NeuRecipe> usages = getAvailableUsagesFor(internalName);
if (usages.isEmpty()) return false;
- Minecraft.getMinecraft().displayGuiScreen(
- new GuiItemRecipe(usages, this));
+ NotEnoughUpdates.INSTANCE.openGui = (new GuiItemRecipe(usages, this));
return true;
}
@@ -957,8 +958,7 @@ public class NEUManager {
if (!recipesMap.containsKey(internalName)) return false;
List<NeuRecipe> recipes = getAvailableRecipesFor(internalName);
if (recipes.isEmpty()) return false;
- Minecraft.getMinecraft().displayGuiScreen(
- new GuiItemRecipe(recipes, this));
+ NotEnoughUpdates.INSTANCE.openGui = (new GuiItemRecipe(recipes, this));
return true;
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/updater/UpdateLoader.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/updater/UpdateLoader.java
index 8d301af7..d358533e 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/updater/UpdateLoader.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/updater/UpdateLoader.java
@@ -19,13 +19,16 @@
package io.github.moulberry.notenoughupdates.miscfeatures.updater;
-import com.google.common.io.Files;
import io.github.moulberry.notenoughupdates.util.NetUtils;
import net.minecraft.client.Minecraft;
+import org.apache.commons.io.IOUtils;
import java.io.File;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
import java.net.URL;
+import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
@@ -98,7 +101,13 @@ abstract class UpdateLoader {
return;
}
ArrayList<File> toDelete = new ArrayList<>();
- for (File sus : mcDataDir.listFiles()) {
+ File[] modFiles = mcDataDir.listFiles();
+ if (modFiles == null) {
+ updater.logProgress("§cCould not list minecraft mod folder (" + mcDataDir + ")");
+ state = State.FAILED;
+ return;
+ }
+ for (File sus : modFiles) {
if (sus.getName().endsWith(".jar")) {
if (updater.isNeuJar(sus)) {
updater.logProgress("Found old NEU file: " + sus + ". Deleting later.");
@@ -107,8 +116,11 @@ abstract class UpdateLoader {
}
}
File dest = new File(mcDataDir, file.getName());
- try {
- Files.copy(file, dest);
+ try (
+ InputStream i = Files.newInputStream(file.toPath());
+ OutputStream o = Files.newOutputStream(dest.toPath());
+ ) {
+ IOUtils.copyLarge(i, o);
} catch (IOException e) {
e.printStackTrace();
updater.logProgress(