Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Bektor

Forge Modder
  • Posts

    852
  • Joined

  • Last visited

Everything posted by Bektor

  1. 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:
  2. 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.
  3. 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.
  4. 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. 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())); } Thx in advance. Bektor
  6. Well: Crafting a bed might need wool, but you might also use stone. Different recipe, same result.
  7. 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?
  8. So what exaclty is a factory in Forge and how does it work?
  9. 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
  10. 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
  11. 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
  12. 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
  13. 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.
  14. 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: 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. Thx in advance. Bektor
  15. @diesieben07 Thx for the help so far with this problem. Guess this had solved the problem. Path zipRoot = fs.getPath("/");
  16. 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 } Guess it's much easier to just buy some 4TB hard drive then creating a ZIP file in Java. ^^
  17. 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.
  18. 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?
  19. 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:
  20. 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?
  21. 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.
  22. 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
×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.