Jump to content

Squidsword

Members
  • Posts

    23
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Squidsword's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. I've searched "Editing JSON file during runtime" and "Editing datapack" and I don't seem to get any relevant results. I don't have much experience with terminology, so I'm not exactly sure what keywords to look up. Do you have a link to the relevant threads? I get what you are saying, but I don't want to put the burden on the user. Especially for my mod, since it's not as simple as just plugging in the values they want into a datapack. Right now, my code will take the rarity that the user sets and generate 3 different placed features that, when summed up, will approximate the rarity they picked. I have the conversion logic in my java code. Before 1.19.3, all the users had to do was set my ore to be say 5x rarer than diamonds, and I could handle the rest of the logic programmatically. I don't want them to have to make 3 different data files and manually compute what values each json file needs to have just to do the same thing. I feel like programmatically setting the JSON values is the only approach to avoid this. Unless you have another approach?
  2. I want to, but I'm not sure how to change the values. Right now, the JSON data is a static copy of the default values and it's not linked to the config in any way. I want to be able to programmatically adjust the JSON files containing the world generation data based on what people set their config to. So, the static copies of the default values are here: configured and placed features There are values like: "discard_chance_on_air_exposure": 0.5, Let's say the user wants the discard chance to be 0.8, so in my mods config file they set it to 0.8. I need to grab that value from the config and relay it over to change it to "discard_chance_on_air_exposure": 0.8,
  3. Hey, I have a mod that adds a couple of new ores. For 1.19.3, I had to move over the logic to JSON files. I want the user to be able to change values such as rarity and vein size and have the JSON file change. Right now, though, all of the JSON files are stuck with the default config values and don't change. The simplest approach I came up with was updating all the JSON files with the configured values right after startup. I tried look at the docs, but I am still not sure how to access and modify the configured and placed feature JSON data on runtime. Do I need to use codecs? I'd appreciate any tips or alternative approaches. Thanks!
  4. I checked 3900 chunks (1000*1000 blocks) by selecting 0 -64 0 to 1000 16 1000 in worldedit and then using the //distr command.
  5. Hey, I am trying to get ore veins to spawn 3x and 9x rarer than diamonds in 1.18.1 and also spawn less ores per vein. I was looking at net.minecraft.data.worldgen.features.OreFeatures and found that diamond uses vein sizes of 4, 8, and 12 for DIAMOND_SMALL, DIAMOND_BURIED, and DIAMOND_LARGE. I already made it so the veins for black opal spawn 9x less than diamond, which worked well. However, when I try to reduce the vein size by 25% for black opal, the ores spawn a lot less than mathematically expected. Here's two imgur links below. Ore Distribution 1 (BLACK_OPAL_SMALL = 4, BLACK_OPAL_BURIED = 8, BLACK_OPAL_LARGE = 12) (same as diamonds) Ore Distribution 2 (BLACK_OPAL_SMALL = 3, BLACK_OPAL_BURIED = 6, BLACK_OPAL_LARGE = 9) (25% vein size reduction) For some reason, Ore Distribution 2 spawned fewer black opals than expected. Amethysts have a similar problem if the same vein sizes are used. It was expected to have around 58421 / 9 * (3 / 4) = 4868 black opal ores. Yet there were only 3578, which is 1.36x rarer than I intended. It ended up more like a 45-50% vein size reduction. Here's the code. I adjusted the vein sizes using the config file (ore dist 1 has black_opal_vein_size at 8, ore dist 2 has it at 6). The ore distributions stats were generated using worldedit's //pos1 //pos2 and //distr commands. OresAboveDiamonds/OreGeneration.java at 1.18.1_test · Squidsword/OresAboveDiamonds (github.com) Anybody have any clues?
  6. Problem solved, thanks ChampionAsh. I used Notepad++ to edit the mods.toml file. On the bottom of Notepad++, there's a line that says Windows CR LF. I clicked on it and changed it to Unix LF, and the boxes were gone. I recently got this weird thing a few weeks ago where the description of my mod has these "carriage return" boxes instead of just going to the next line. The text file encoding is UTF-8. I dismissed it at first since it wasn't very important but I haven't found a resolution yet and it's getting on my nerves. I use eclipse and to edit it, and I just used the windows notepad to make changes to the file. I have no idea what I did to mess it up like this. Does anybody know what's going on? Here's the mods.toml file. modLoader="javafml" #mandatory loaderVersion="[34,)" #mandatory (35 is current forge version) issueTrackerURL="https://github.com/Squidsword/OresAboveDiamonds/issues" license="MIT" [[mods]] #mandatory modId="oresabovediamonds" #mandatory version="6.2.0" #mandatory displayURL="https://www.curseforge.com/minecraft/mc-mods/ores-above-diamonds" #optional displayName="Ores Above Diamonds" #mandatory logoFile="oresabovediamonds_logo.png" #optional # A text field displayed in the mod UI authors="§dSquidsword" #optional credits="Special thanks to §6CriativeMan1§r for the making the art for this mod!" # The description text for the mod (multi line!) (#mandatory) description=''' Adds the §dAmethyst§r and §5Black Opal§r which are respectively §d3x§r and §59x§r rarer than diamonds. Both have its own set of balanced armors and tools. It's recommended to download Overloaded Armor Bar along with this mod. https://www.curseforge.com/minecraft/mc-mods/overloaded-armor-bar/ The mod doesn't have built in retrogen support. This means that ores will not spawn in already loaded chunks. Venture far into unexplored lands to have a chance at finding them. ''' # Here's another dependency [[dependencies.oresabovediamonds]] modId="forge" mandatory=true versionRange="[34.0.0,)" ordering="NONE" side="BOTH" [[dependencies.oresabovediamonds]] modId="minecraft" mandatory=true versionRange="[1.16.3,)" ordering="NONE" side="BOTH" Here's the repository.
  7. Wow thanks, I don't know how I missed that. You're definitely right, I wrote it before I took any java classes so it's super sloppy. I took an intro class since and I think I'm going to make some helper methods to reduce the horizontal space needed and maybe make an array instead of doing it all one by one so it'll trim the lines of code down by a bit. Anyway, problem solved!
  8. I checked the docs and I don't think anything changed. I debugged the client and put a breakpoint at decode and handle and none of them were going off. Here's the source code if it helps (it's a little sloppy). The 1.15.2 branch is pretty much the same and it works fine, the only difference in 1.16.1 and 1.16.4 I added some config options for some new gear. Both 1.16.1 and 1.16.4 have the same problem. I double checked the additions to make sure I didn't make any typos, and I don't think I did. I don't understand the system very well and I'm really confused and I'm not sure what is going on. I'm probably missing something obvious lol. I'd really appreciate any help; let me know if you guys need any more data.
  9. Here's the crash report Here's my build.gradle Here's the source code if still needed I'm not sure what I'm doing so I'd appreciate some help. I think it has to do with my mappings or something? It gives a java.lang.NoSuchMethodError: 'net.minecraft.client.Minecraft net.minecraft.client.Minecraft.func_71410_x()' I think func_71410_x() is supposed to be getInstance() in deobfuscated form. I'm very influent in programming so don't be too harsh on me lol.
  10. I have an eclipse gradle project with a Minecraft mod dealing with ore generation and I want to add the Advanced Xray Mod by Error_MiKeY for testing purposes. I'm not planning on distributing his mod with mine, I just want to be able to test my mod within my workspace without having to build a jar file and put both files into actual Minecraft and run it there every time I want to test something. What I've tried and what sometimes works with other mods is adding the mod's .jar file to the run\mods folder. However, when I put the Advanced Xray mod in there, I get "Advanced Xray has class loading errors" (crash report here). The mod calls a method called Minecraft.func_7140_x(), and it returns a NoSuchMethod error, even though both mods are on the same version 1.16.4. They both work when I build my mod and add it to the mod files in Minecraft and run it on the actual game, so why doesn't it work here? Is it because my workspace is set up incorrectly? I heard that it's because it's not deobfuscated, but I'm not sure how to deobfuscate it without a tool like BON2 to do it for me and I can only go up to 1.15 on that. I've researched it and I heard that you can also put a dependency on your build.gradle file and it will download it online. I don't really have an understanding of how it works so I got lost in this step. What URL do I put? The mod is on GitHub, so do I add a GitHub repository with the link to the GitHub and grab it from there? I'm not sure. I also heard another way to add a dependency is to add a libs folder on your project root directory and put it there. By that do they mean making a new libs folder on the outermost layer where the build, settings, and src folders are or are they talking about the libs folder in \build? If the former, I tried making a libs folder like this and then I added the .jar file to it but nothing happened. I clearly don't know what I'm doing so don't overestimate how many things I know lol. I'd appreciate any help, thanks.
  11. Thanks, that sounds like a more efficient solution but I feel like I'm going to have to put a lot of work for my level of programming, I'm not sure if I'll be able to do it or not.
  12. You're absolutely right, the config file on the server side will still take effect on all the clients. The only problem is that the players can't see some of the changes in their HUD since their own config file is different. The packet is for a client-side only change that will update the HUDs of the items by registering the proper config values so they will render properly after the restart, as you already said. I am not familiar with how ForgeConfigSpec works or how to change the file values in an efficient way, so I'm having a problem actually changing the values within the code itself.
  13. I do want the user to be able to customize their own config values as normal. For more details, when the player joins a minecraft server with the mod enabled, I want the client config to change to the servers values so the player can see the changes the server has made. I have config values that can change the damage and armor values of the items in my mod (which a minecraft restart to take effect or so I believe). I'm not sure if there is a simpler way to do this other than sending a packet and changing the values using the packet message. The problem I'm not sure how to change it from within the packet handler because I'm not sure how to set the values from within the code. I am not sure what you mean by change it to the config version, do you mean set the default value to the packet values from the server in the ForgeConfigSpec builder .define method?
  14. Hey guys, I am trying to send a packet to the client when he enters the server to update his config files. In 1.12.2 it was rather easy with the @Config annotation, however I am having difficulty finding ways to change ForgeConfigSpec values in the packet handler I just made. I am a new programmer and I am not really sure of the most efficient way to do so. final ForgeConfigSpec.BooleanValue overworld_ores; final ForgeConfigSpec.BooleanValue nether_ores; final ForgeConfigSpec.BooleanValue end_ores; ServerConfig(final ForgeConfigSpec.Builder builder) { builder.comment("Note that almost all config changes require a server restart. Dimensional Ore Configuration").push("dimensional_ore"); overworld_ores = builder .comment("Spawn ores in the overworld? Default = true") .define("overworld_ores", true); nether_ores = builder .comment("Spawn ores in the nether? Default = false") .define("nether_ores", false); end_ores = builder .comment("Spawn ores in the end? Default = false") .define("end_ores", false); builder.pop(); } Here's a snippet of the way I created the values. It writes the default value in the config value, but how do I set the value to something other than the default without manually going to the .toml file and rewriting new ones? Is there any way to do it within the code? Thanks for any help.
  15. Thank you everybody. I came up with a solution using AnvilUpdateEvent. For anyone who might stumble upon this in the future, here's the code. A lot of this code was pasted from RepairContainer with some if statements added in. For some reason the formatting is weird, oh well. package oresAboveDiamonds.OresMod.events; import java.util.Map; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraftforge.event.AnvilUpdateEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; public class AnvilUpdateEventHandler { @SubscribeEvent(priority = EventPriority.LOW) public void anvilEvent(AnvilUpdateEvent event) { ItemStack left = event.getLeft(); ItemStack right = event.getRight(); if(left.getMaxDamage() <= 0 && right.getItem() != Items.ENCHANTED_BOOK && left.getItem().equals(right.getItem())) { Map<Enchantment, Integer> map = EnchantmentHelper.getEnchantments(left); Map<Enchantment, Integer> map1 = EnchantmentHelper.getEnchantments(right); for(Enchantment enchantment1 : map1.keySet()) { if (enchantment1 != null) { int i2 = map.containsKey(enchantment1) ? map.get(enchantment1) : 0; int j2 = map1.get(enchantment1); j2 = i2 == j2 ? j2 + 1 : Math.max(j2, i2); if(j2 > enchantment1.getMaxLevel()) { j2 = enchantment1.getMaxLevel(); } map.put(enchantment1, j2); } } ItemStack output = left.copy(); EnchantmentHelper.setEnchantments(map, output); event.setOutput(output); } } }
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.