Backwards Coppertability

- Added the option to ship opt-in resource packs
This commit is contained in:
simibubi 2021-12-05 14:05:57 +01:00
parent 38b656b501
commit 55b13bf421
3 changed files with 35 additions and 0 deletions

View File

@ -31,6 +31,7 @@ import com.simibubi.create.foundation.data.recipe.ProcessingRecipeGen;
import com.simibubi.create.foundation.data.recipe.SequencedAssemblyRecipeGen;
import com.simibubi.create.foundation.data.recipe.StandardRecipeGen;
import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.utility.ShippedResourcePacks;
import com.simibubi.create.foundation.worldgen.AllWorldFeatures;
import com.tterrag.registrate.util.NonNullLazyValue;
@ -131,6 +132,7 @@ public class Create {
BuiltinPotatoProjectileTypes.register();
CHUNK_UTIL.init();
ShippedResourcePacks.extractFiles("Copper Legacy Pack");
event.enqueueWork(() -> {
AllTriggers.register();

View File

@ -0,0 +1,33 @@
package com.simibubi.create.foundation.utility;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.FileAlreadyExistsException;
import java.nio.file.Files;
import java.nio.file.Paths;
public class ShippedResourcePacks {
public static void extractFiles(String... packs) {
FilesHelper.createFolderIfMissing("resourcepacks");
for (String name : packs) {
InputStream folderInJar = ShippedResourcePacks.class.getResourceAsStream("/opt_in/" + name + ".zip");
try {
Files.copy(folderInJar, Paths.get("resourcepacks/" + name + ".zip"));
} catch (FileAlreadyExistsException e) {
} catch (IOException e) {
e.printStackTrace();
}
try {
folderInJar.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}

Binary file not shown.