-
Posts
852 -
Joined
-
Last visited
Posts posted by Bektor
-
-
Hi,
whenever I'm trying to register my biomes and later call BiomeDictionary.addTypes I'm getting the following problem: Caused by: java.lang.IllegalArgumentException: Cannot add types to unregistered biome null
@ObjectHolder(Constants.MOD_ID) public class ModBiomes { public static final BiomeDeepForest deepForest = null; @Mod.EventBusSubscriber(modid = Constants.MOD_ID) public static class RegistrationHandler { @SubscribeEvent public static void registerBiomes(final RegistryEvent.Register<Biome> event) { final IForgeRegistry<Biome> registry = event.getRegistry(); System.out.println("Registering biomes..."); // this line is called registry.register(new BiomeDeepForest().setRegistryName(Constants.MOD_ID, ModWorldGen.BIOME_NAME)); } } // Called at the end of FMLInitializationEvent public static void initBiomeManagerAndDictionary() { System.out.println("Init Biome Manager and Dictionary..."); // this line is called BiomeManager.addBiome(BiomeType.WARM, new BiomeEntry(deepForest, 10)); BiomeManager.addSpawnBiome(deepForest); BiomeDictionary.addTypes(deepForest, // Exception occurs here! BiomeDictionary.Type.FOREST, BiomeDictionary.Type.DENSE); } }
Crash log:
SpoilerCaused by: java.lang.IllegalArgumentException: Cannot add types to unregistered biome null at com.google.common.base.Preconditions.checkArgument(Preconditions.java:191) at net.minecraftforge.common.BiomeDictionary.addTypes(BiomeDictionary.java:185) at testmod.world.ModBiomes.initBiomeManagerAndDictionary(ModBiomes.java:50) at testmod.TestMod.init(TestMod.java:71) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:626) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91) at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150) at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76) at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399) at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71) at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116) at com.google.common.eventbus.EventBus.post(EventBus.java:217) at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:219) at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:197) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91) at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150) at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76) at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399) at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71) at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116) at com.google.common.eventbus.EventBus.post(EventBus.java:217) at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:136) at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:744) at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:336) at net.minecraft.client.Minecraft.init(Minecraft.java:582) at net.minecraft.client.Minecraft.run(Minecraft.java:422) at net.minecraft.client.main.Main.main(Main.java:118) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) at GradleStart.main(GradleStart.java:25)
-
9 hours ago, Animefan8888 said:
Gui#drawModalRectWithCustomSizedTexture
Thx, this solved the problem.
-
13 hours ago, Draco18s said:
Oh.
Different problem.
drawTexturedModalRect assumes textures are both square and 256 pixels wide. Your texture is 30 pixels wide and you're trying to draw all 30 pixels. What's actually being drawn is the top left corner (3.5 pixels worth).
How can I draw a texture with 30x30px?
I'm also wondering how I could scale this texture, for example when the UI element is smaller than the texture, but the full texture should be drawn within this smaller UI element.
-
11 minutes ago, Draco18s said:
More accurately, its drawing your texture with no lighting. Even if your texture was white it would render black.
You need to disable lighting.
It is rendering a white texture just fine (as a white texture), a black texture is rendered just fine, a red texture is rendered just fine.
But now matter what colors the texture has, the question mark will not be drawn (tested with black and transparent background, red and white question marks).
My class just extends GuiButton and doesn't overwrite anything else except for this method.
-
Hi there,
I'm having the problem that my GUI only renders one color of my texture.
@Override public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks) { if(this.enabled && this.visible) { GlStateManager.color(1.f, 1.f, 1.f, 1.f); ResourceLocation BUTTON_ICON = new ResourceLocation(Constants.MOD_ID, "textures/gui/icon_test.png"); mc.getTextureManager().bindTexture(BUTTON_ICON); this.drawTexturedModalRect(this.x, this.y, 0, 0, 30, 30); this.drawCenteredString(mc.fontRenderer, this.displayString, this.x + 40, this.y + (this.height - 8) / 2, 0xFFFFFF); } }
This piece of code only ever results into a blank texture beeing drawn instead of the (for test purposes) question mark within it beeing drawn. The texture is 32 by 32 px large.
Chaning the background of the test texture from black to transparent makes it impossible to see anything of the texture at all.
Thx in advance.
Bektor
-
5 minutes ago, jabelar said:
This is a Java thing about modifying certain types of collections (like List) while iterating through it. You need to use a proper iterator and safe methods instead of a for loop. See discussion here: https://stackoverflow.com/questions/15384486/java-concurrent-modification-exception-error
Ok, thx.
-
Hi there,
I've got a small problem:
I got back to my old source code and wanted to finish the GUI, thought for some reason I'm running into a ConcurrentModificationException at the starting line of the for-loop.
--> Code is located at the beginning of initGui() this.buttonList.clear(); this.categories = new ArrayList<>(JustAnotherEnergyAPI.getAllCategories()); this.categories.sort(Comparator .comparingInt((LexiconCategory c) -> c.getModID().equals(Constants.MOD_ID) ? 0 : 1) .thenComparing(Comparator.comparing(LexiconCategory::getModID)) .thenComparing(Comparator.comparing(LexiconCategory::getPriority)) ); for(LexiconCategory category : this.categories) { // TODO: limit number of categories per page this.categories.add(category); this.buttonList.add(new GuiButtonCategory(category.getPriority(), this.left + 20, this.top + 20, this.guiWidth, 30, category.getUnlocalisedName())); }
Quote[main/FATAL] [net.minecraft.client.Minecraft]: Unreported exception thrown! java.util.ConcurrentModificationException: null at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:901) ~[?:1.8.0_144] at java.util.ArrayList$Itr.next(ArrayList.java:851) ~[?:1.8.0_144] at minecraftplaye.justanotherenergy.client.gui.GuiModBook.initGui(GuiModBook.java:74) ~[GuiModBook.class:?] at net.minecraft.client.gui.GuiScreen.setWorldAndResolution(GuiScreen.java:543) ~[GuiScreen.class:?] at net.minecraft.client.Minecraft.displayGuiScreen(Minecraft.java:1096) ~[Minecraft.class:?] at net.minecraftforge.fml.client.FMLClientHandler.showGuiScreen(FMLClientHandler.java:534) ~[FMLClientHandler.class:?] at net.minecraftforge.fml.common.FMLCommonHandler.showGuiScreen(FMLCommonHandler.java:321) ~[FMLCommonHandler.class:?] at net.minecraftforge.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:112) ~[FMLNetworkHandler.class:?] at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2809) ~[EntityPlayer.class:?] at minecraftplaye.justanotherenergy.common.items.ItemLexicon.onItemRightClick(ItemLexicon.java:41) ~[ItemLexicon.class:?] at net.minecraft.item.ItemStack.useItemRightClick(ItemStack.java:234) ~[ItemStack.class:?] at net.minecraft.client.multiplayer.PlayerControllerMP.processRightClick(PlayerControllerMP.java:543) ~[PlayerControllerMP.class:?] at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1710) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.processKeyBinds(Minecraft.java:2379) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.runTickKeyboard(Minecraft.java:2145) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.runTick(Minecraft.java:1933) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1186) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:441) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_144] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_144] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_144] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_144] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_144] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_144] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_144] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_144] at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?] at GradleStart.main(GradleStart.java:25) [start/:?]
Thx in advance.
Bektor
-
2 minutes ago, Draco18s said:
Probably not. I mean how would that work, a bucket of milk returns a glass bottle, but a bucket of water returns a bucket?
Well: Crafting a bed might need wool, but you might also use stone.
Different recipe, same result.
-
On 5/17/2018 at 6:35 PM, Draco18s said:
Buckets of liquids automatically return an empty bucket due to the Container Item mechanics. This has nothing to do with the recipe.
But what about custom items?
I'm also wondering if it is possible to define multiply recipes for the same item and how this should be done?
-
12 minutes ago, Draco18s said:
You need a _factories.json file:
QuoteSo what exaclty is a factory in Forge and how does it work?
-
Hi there,
I've got a few questions regarding recipes in Forge 1.12.2:
- What 'types' does forge come with besides the normal minecraft:shaped_recipe and minecraft:smelting stuff.
- How can one register his own type.
- How can I create a recipe which returns multiply different items, for example an emtpy bucket and an apple (in this case a full bucket was provided) or an apple and a dirt block.
Thx in advance.
Bektor
EDIT: see here
-
Hi,
I'm wondering what things I can test with JUnit 5 of my mod as I
know that Minecraft is a bit limited in terms of what can be tested and what can't.
Thx in advance.
Bektor
-
Hi,
I'm wondering how I can change mod mappings in order to convert some
changed block names over to the new names as I'm currently refactoring my
complete src code like every few months and don't want to re-create my entire
test world again.
Thx in advance.
Bektor
-
Hi there,
I want to know wether it is possible to use the new
plugins { id 'java' id 'eclipse' id 'idea' }
syntax for the net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT plugin, as it seems to be that there are multiply different types of plugins
with different requirements for this syntax: https://docs.gradle.org/current/userguide/plugins.html
I don't know when this new sytanx was added, but I'm currently upgrading to Gradle 4.6 because of it's native JUnit 5 support.
Thx in advance.
Bektor
-
46 minutes ago, diesieben07 said:
I urge you to not write threading code manually.
This makes me wonder why those classes are still around in Java. I've used them since I started with Java in Java 7 times.
-
Hi,
I've got a problem that I want to save some copied files with my Minecraft Mod, but I want this to be handled on an extra thread.
The problem is that I'm getting up to 5 temp files which contain my files instead of 1 zip file.
public synchronized void start(Path path) { // Set the path here as it might have changed before the thread starts the backup process this.directory = path.resolve("tests.zip"); this.thread = new Thread(this, "World Backup Thread"); this.thread.setPriority(7); this.thread.start(); } public synchronized void stop() { try { this.thread.join(); } catch (InterruptedException e) { ServerUtilities.LOGGER.fatal(e); } } @Override public void run() { if(!this.isDone) this.createZipFile(); this.isDone = true; // at ThreadBackups.run(ThreadBackups.java:56) } private void createZipFile() { ImmutableMap immutableMap = ImmutableMap.of("create", String.valueOf(Files.notExists(this.directory))); FileSystemProvider zipProvider = FileSystemProvider.installedProviders().stream() .filter(provider -> provider.getScheme().equals("jar")).findFirst().get(); try(FileSystem fs = zipProvider.newFileSystem(this.directory, immutableMap)) { Path root = fs.getPath("/"); // this.world = path to the worldPath on which saving was disabled beforehand using world.disableLevelSaving = true; Files.walk(this.worldPath).forEach((Path sourcePath) -> { try { Path destination = root; for(Path p : this.worldPath.relativize(sourcePath)) destination = destination.resolve(p.toString()); if(!Files.isDirectory(destination) || !Files.isDirectory(sourcePath)) Files.copy(sourcePath, destination); } catch(IOException e) { e.printStackTrace(); } }); } catch(IOException e) { e.printStackTrace(); } // ThreadBackups.createZipFile(ThreadBackups.java:81) }
// within TickEvent.ServerTickEvent [...] // disables all level saving and then calls the thread to start! Backups.INSTANCE.start(Backups.INSTANCE.server, ""); // returns the isDone value from the thread to which this class holds no reference as the Backups class created it if(Backups.INSTANCE.isDone()) { Backups.INSTANCE.stop(); // stops the whole thread by only calling the stop method in the thread class timeTillBackup = ModConfig.Backup.timeTillBackup; } [...]
It also causes and AccessDeniedException for the zip file to be created as it can't find the zip file, thus causing a NoSuchFileException after the first exception.
Backups is not the class shown here! Backups holds an instance to the thread and calls the start/stop methods in the thread class which are posted here like the thread itself.
The start method in Backups disables level saving and calls afterwards the start method of the thread to start the backup process. The stop method of Backups does nothing but to call the
stop of the thread itself while isDone returns the boolean isDone from the thread.
This means the thread itself does nothing more as to create the files. All other logic is handles in other classes.
Exceptions:
Spoiler[backups.ThreadBackups:createZipFile:82]: java.nio.file.AccessDeniedException: .\backups\tests.zip [backups.ThreadBackups:createZipFile:82]: at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:83) [backups.ThreadBackups:createZipFile:82]: at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97) [backups.ThreadBackups:createZipFile:82]: at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102) [backups.ThreadBackups:createZipFile:82]: at sun.nio.fs.WindowsFileSystemProvider.implDelete(WindowsFileSystemProvider.java:269) [backups.ThreadBackups:createZipFile:82]: at sun.nio.fs.AbstractFileSystemProvider.delete(AbstractFileSystemProvider.java:103) [backups.ThreadBackups:createZipFile:82]: at java.nio.file.Files.delete(Files.java:1126) [backups.ThreadBackups:createZipFile:82]: at com.sun.nio.zipfs.ZipFileSystem.sync(ZipFileSystem.java:1294) [backups.ThreadBackups:createZipFile:82]: at com.sun.nio.zipfs.ZipFileSystem.close(ZipFileSystem.java:277) [backups.ThreadBackups:createZipFile:82]: at backups.ThreadBackups.createZipFile(ThreadBackups.java:81) [backups.ThreadBackups:createZipFile:82]: at backups.ThreadBackups.run(ThreadBackups.java:56) [backups.ThreadBackups:createZipFile:82]: at java.lang.Thread.run(Thread.java:748) [backups.ThreadBackups:createZipFile:82]: java.nio.file.NoSuchFileException: .\backups\tests.zip [backups.ThreadBackups:createZipFile:82]: at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:79) [backups.ThreadBackups:createZipFile:82]: at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97) [backups.ThreadBackups:createZipFile:82]: at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102) [backups.ThreadBackups:createZipFile:82]: at sun.nio.fs.WindowsFileSystemProvider.implDelete(WindowsFileSystemProvider.java:269) [backups.ThreadBackups:createZipFile:82]: at sun.nio.fs.AbstractFileSystemProvider.delete(AbstractFileSystemProvider.java:103) [backups.ThreadBackups:createZipFile:82]: at java.nio.file.Files.delete(Files.java:1126) [backups.ThreadBackups:createZipFile:82]: at com.sun.nio.zipfs.ZipFileSystem.sync(ZipFileSystem.java:1294) [backups.ThreadBackups:createZipFile:82]: at com.sun.nio.zipfs.ZipFileSystem.close(ZipFileSystem.java:277) [backups.ThreadBackups:createZipFile:82]: at backups.ThreadBackups.createZipFile(ThreadBackups.java:81) [backups.ThreadBackups:createZipFile:82]: at backups.ThreadBackups.run(ThreadBackups.java:56) [backups.ThreadBackups:createZipFile:82]: at java.lang.Thread.run(Thread.java:748)
I should note that I also tested if it is possible to write ZIP files within a thread and that just works fine, thought in Minecraft it doesn't.
Spoilerpublic class ZipTest implements Runnable { private Thread thread; public boolean done = false; public void start() { this.thread = new Thread(this); thread.start(); } public void stop() { try { thread.join(); } catch (InterruptedException e) { e.printStackTrace(); } } public void run() { Path dest = Paths.get("test.zip"); Path src = Paths.get("Test"); Map<String, String> env = Collections.singletonMap("create", "true"); FileSystemProvider zipProvider = FileSystemProvider.installedProviders().stream() .filter(provider -> provider.getScheme().equals("jar")).findFirst().get(); try(FileSystem fs = zipProvider.newFileSystem(dest, env)) { Path root = fs.getPath("/"); Files.walk(src).forEach((Path sourcePath) -> { try { Path destination = root; for(Path p : src.relativize(sourcePath)) destination = destination.resolve(p.toString()); System.out.println(destination.toString()); if(!Files.isDirectory(destination) || !Files.isDirectory(sourcePath)) Files.copy(sourcePath, destination); } catch (IOException e) { e.printStackTrace(); } }); } catch (IOException e) { e.printStackTrace(); } done = true; } public static void main(String[] args) { ZipTest test = new ZipTest(); test.start(); if(test.done) test.stop(); } }
Thx in advance.
Bektor
-
@diesieben07 Thx for the help so far with this problem.
Guess this had solved the problem.
Path zipRoot = fs.getPath("/");
-
7 hours ago, diesieben07 said:
The zip file system needs to be told explicitly that it needs to create the file. This is not straightforward with the API found in the FileSystems class and would require manual URI creation. I suggest this way:
FileSystemProvider zipProvider = FileSystemProvider.installedProviders().stream().filter(provider -> provider.getScheme().equals("jar")).findFirst().get(); FileSystem fs = zipProvider.newFileSystem(path, ImmutableMap.of("create", "true"));
Hm.. I'm wondering: When using FileSystemProvider etc. how should I add files to a ZIP file and is it possible to set the compression level?
// this.world = DimensionManager.getCurrentSaveRootDirectory().toPath(); // fs = FileSystem try { Files.walk(this.world).filter(path -> !Files.isDirectory(path)) .forEach((Path path) -> { try { Files.copy(this.world.resolve(path), fs.getPath(path.toString()), StandardCopyOption.REPLACE_EXISTING); } catch (IOException e) { e.printStackTrace(); } }); } catch (IOException e) { e.printStackTrace(); // TODO: use logger }
Spoilerjava.nio.file.NoSuchFileException: .\world\.\world\session.lock at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:79) at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97) at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102) at sun.nio.fs.WindowsFileAttributeViews$Basic.readAttributes(WindowsFileAttributeViews.java:53) at sun.nio.fs.WindowsFileAttributeViews$Basic.readAttributes(WindowsFileAttributeViews.java:38) at sun.nio.fs.WindowsFileSystemProvider.readAttributes(WindowsFileSystemProvider.java:193) at java.nio.file.Files.readAttributes(Files.java:1737) at java.nio.file.CopyMoveHelper.copyToForeignTarget(CopyMoveHelper.java:109) at java.nio.file.Files.copy(Files.java:1277) at minecraftplaye.serverutilities.backups.ThreadBackups.lambda$copyFilesToArchive$2(ThreadBackups.java:114) at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184) at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175) at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) at java.util.Iterator.forEachRemaining(Iterator.java:116) at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801) at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481) at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151) at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174) at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418) at minecraftplaye.serverutilities.backups.ThreadBackups.copyFilesToArchive(ThreadBackups.java:110) at minecraftplaye.serverutilities.backups.ThreadBackups.createZipFile(ThreadBackups.java:78) at minecraftplaye.serverutilities.backups.ThreadBackups.run(ThreadBackups.java:56) at java.lang.Thread.run(Thread.java:748)
Guess it's much easier to just buy some 4TB hard drive then creating a ZIP file in Java. ^^
-
8 minutes ago, diesieben07 said:
Files.createFile creates an empty file. That is not a valid zip file.
Ask the authors of the zip filesystem provider
I guess someone should take the time to rewrite the whole ZIP API. ^^
Thought it is quite interesting how people go about using ZipEntry and others go with Files.copy while others do it completly different.
-
5 hours ago, diesieben07 said:
The zip file system needs to be told explicitly that it needs to create the file. This is not straightforward with the API found in the FileSystems class and would require manual URI creation. I suggest this way:
FileSystemProvider zipProvider = FileSystemProvider.installedProviders().stream().filter(provider -> provider.getScheme().equals("jar")).findFirst().get(); FileSystem fs = zipProvider.newFileSystem(path, ImmutableMap.of("create", "true"));
Hm.. Wouldn't it make much more sense to just use Files.createFile? I mean, I don't see any benefit of using these two lines if one line of code could do the same?
What would be the benefits of using your approach vs Files.createFile??
And why do I have to use the argumentjar there instead of zip?
-
4 hours ago, diesieben07 said:
No. It works by returning the resolved path. You are ignoring the return value and continuing to use the "unresolved" path.
Oh... guess it wasn't that great of an idea to start programming late in the evening... ^^
// it is the same path as from the posts before, just in the backup thread which is located in another class, so I'm storing within the // thread a local reference/variable this.directionary = path; this.directionary.resolve("test.zip"); // changed to this: this.directionary = path.resolve("test.zip");
Thought even when changing this the error still occurs:
Quote[java.lang.ThreadGroup:uncaughtException:1052]: java.nio.file.FileSystemNotFoundException: .\backups\test.zip [java.lang.ThreadGroup:uncaughtException:1052]: at com.sun.nio.zipfs.ZipFileSystem.<init>(ZipFileSystem.java:120) [java.lang.ThreadGroup:uncaughtException:1052]: at com.sun.nio.zipfs.ZipFileSystemProvider.newFileSystem(ZipFileSystemProvider.java:139) [java.lang.ThreadGroup:uncaughtException:1052]: at java.nio.file.FileSystems.newFileSystem(FileSystems.java:390) [java.lang.ThreadGroup:uncaughtException:1052]: at minecraftplaye.serverutilities.backups.ThreadBackups.createZipFile(ThreadBackups.java:71) [java.lang.ThreadGroup:uncaughtException:1052]: at minecraftplaye.serverutilities.backups.ThreadBackups.run(ThreadBackups.java:53) [java.lang.ThreadGroup:uncaughtException:1052]: at java.lang.Thread.run(Thread.java:748)
-
9 hours ago, diesieben07 said:
You are not understanding how resolve works. Read my previous posts.
Meaning that resolve doesn't work for combining a path with a file?
How am I to create this path then using my already existing path?
-
7 minutes ago, diesieben07 said:
If you want to create a file system for a zip file, you need to pass in a path to a zip file. Or at least a path that ends with .zip. You can't pass in a path that points to an existing directory and expect to get some magic zip file out.
My path ends with a .zip as can be seen in my previous posts. And I basically want to create a new zip file and copy the whole world into it.
-
1 minute ago, diesieben07 said:
You are trying to create a file system from a directory.
This does nothing. You create the new path (returned by resolve) and then drop the object on the floor and forget about it.
How would I go about creating it then? I never worked with zip files and not much with file systems before, so I just read the docs here: https://docs.oracle.com/javase/8/docs/technotes/guides/io/fsp/zipfilesystemprovider.html
[1.12.2][SOLVED] Register Biomes and add types crashes
in Modder Support
Posted
Ah, ok. Thx.