Jump to content

Recommended Posts

Posted

Hi all,

 

I need to define items in external config files for reference in my mod's content files. Until now I've done this simply enough in the following way:

 

wool_black;minecraft:wool;15
wool_blue;minecraft:wool;11
wool_brown;minecraft:wool;12
wool_cyan;minecraft:wool;9
wool_gray;minecraft:wool;7
wool_green;minecraft:wool;13

 

Where the first value is an internal name for my mod and the next values are the Minecraft item name and the meta value. Works very well except for items dependent on item-stack level NBT data. Is there any way of storing (simple) NBT data in single-line string format that I could use rather than code mine? Obviously not for really complicated data structure, but say to store the data needed to define a potion for example?

 

Thanks

Posted

There are a number of classes such as the JsonToNBT, the CompressedStreamTools, and even methods in the NBTBase class that deal with various approaches to serialization of NBT. I haven't used them myself, but I assume they are close to what you're looking for. Just check out how they are used in vanilla.

  • Thanks 1

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

  • 8 months later...
Posted (edited)

I actually just started looking into this as well.  I'll keep this open in a tab and go check the vanilla classes first as suggested.

 

Egad, somehow I misread the last post date on this thread; sorry about that.

Edited by Laike_Endaril
Posted

I don’t think there’s any way to decide what parts of the NBT are “important” and which parts arent

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted (edited)

Aye, my goal is the same (to allow users to specify items with nbt in a config String array input).

 

Alternatively, if there is a good way to do something similar with submenus (categories), that would be even better for my case, as I could allow them to add an entry, which would be a new config button, which they could then click on...and then inside the dynamically-created config menu it sends them to I would have a field for the base item name/meta, a string array input for multiple nbt tags, etc, etc.  I don't think this is really a thing or I'd think I would've seen it by now, but I could be wrong.

 

Back to the NBT, it's difficult to decide how to implement it in order to strike a balance between complexity and flexibility for the end-user.  I'm trying to avoid external JSON files because I feel many users would be put-off by them.  At the same time though, doing a full JSON-format NBT compound in a one-line string input field can get confusing without using an external text editor to write it out first.  I started writing my own syntax for a simplified input that just uses tiered string splitting, but even that got very complicated to put entries into...being able to split the entry into multiple different input fields would be ideal, but I need an unknown number of them, thus the want of a config array input.  Is that a thing?

 

Edit: I suppose I could accomplish this by writing my own GUI, but I would want to link access to my GUI to the normal forge mod config menu if I did, and I'm not sure how that would be done either.

Edited by Laike_Endaril
Posted
1 hour ago, Laike_Endaril said:

but I would want to link access to my GUI to the normal forge mod config menu if I did, and I'm not sure how that would be done either.

Extend GuiConfig and pass the name of the class to guiClassName in @Mod

  • Thanks 1

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted (edited)
3 hours ago, Cadiboo said:

pass the name of the class to guiClassName in @Mod


I've unfortunately been unable to figure this out.  I had assumed it would be doable in the @Mod tag of the main mod class, but the only gui related thing in there seems to be guiFactory.

I tried messing with the guiFactory argument in the @Mod tag since I had stumbled upon it, and ended up with this so far:

 

@Mod(modid = DynamicStealth.MODID, name = DynamicStealth.NAME, version = DynamicStealth.VERSION, guiFactory = "com.fantasticsource.dynamicstealth.config.DynamicStealthConfigFactory")

 

...and...

 

package com.fantasticsource.dynamicstealth.config;

import com.fantasticsource.dynamicstealth.common.DynamicStealth;
import net.minecraftforge.fml.client.DefaultGuiFactory;

public class DynamicStealthConfigFactory extends DefaultGuiFactory
{
    public DynamicStealthConfigFactory()
    {
        super(DynamicStealth.MODID, DynamicStealth.NAME);
    }
}

 

Which does work...it loads the same config files as usual, and everything works as expected.  Next I'll try overriding createConfigGui and having it return an instance of a custom class extending GuiConfig and see where that gets me.

Side note: I tried making the above class in a general-use context at first, but even though DefaultGuiFactory uses a 2-argument constructor, it seems if you define your own guiFactory in the @Mod tag, it only searches for a 0-argument constructor.  Maybe there is some syntax that can be used in the @Mod reference to make it look for a constructor with arguments, bug I haven't the slightest idea how that would be structured if there is.


In any case, this possible solution is going to be far more...adventurous...than I would've hoped, if it ends up working, and certainly goes far beyond a "simple" solution for specifying items with NBT in your config in a reasonable manner.  Nonetheless I'll try to get it working in as general a way as possible and if I manage it, will post the code.

Edited by Laike_Endaril
Formatting
Posted

In my case, I'm trying to avoid external files, though that may be viable for Kinniken?  I'm not sure.

 

In my particular case, I'm attempting to allow users to enter an item with many properties attached to it without the entry getting complex, so I basically need to split it into multiple inputs.  I also want the user to be able to enter any number of items this way, all without having to edit an external file, so for now I'll continue trying to manipulate the config menu itself with the goal of making what basically amounts to a category array.

Posted (edited)

After a couple days messing with it, I've decided to cave in and use a normal String[] config with a token parse...so I'm currently writing code for that approach.

 

Edit: My code is working.  I've tried to make it a bit simpler than a normal NBT string so I did my own parsing, which means the code itself is much more complex than it would otherwise be, but hopefully it makes things a bit easier on the user...we'll see.

 

Will only post link to code if someone requests it; it is likely more complex than most would want to look at for what it does

Edited by Laike_Endaril

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • When I first heard about Bitcoin back in 2018, I was skeptical. The idea of a decentralized, digital currency seemed too good to be true. But I was intrigued as I learned more about the technology behind it and its potential. I started small, investing just a few hundred dollars, dipping my toes into the cryptocurrency waters. At first, it was exhilarating to watch the value of my investment grow exponentially. I felt like I was part of the future, an early adopter of this revolutionary new asset. But that euphoria was short-lived. One day, I logged into my digital wallet only to find it empty - my Bitcoin had vanished without a trace. It turned out that the online exchange I had trusted had been hacked, and my funds were stolen. I was devastated, both financially and emotionally. All the potential I had seen in Bitcoin was tainted by the harsh reality that with decentralization came a lack of regulation and oversight. My hard-earned money was gone, lost to the ether of the digital world. This experience taught me a painful lesson about the price of trust in the uncharted territory of cryptocurrency. While the technology holds incredible promise, the risks can be catastrophic if you don't approach it with extreme caution. My Bitcoin investment gamble had failed, and I was left to pick up the pieces, wiser but poorer for having placed my faith in the wrong hands. My sincere appreciation goes to MUYERN TRUST HACKER. You are my hero in recovering my lost funds. Send a direct m a i l ( muyerntrusted ( @ ) mail-me ( . )c o m ) or message on whats app : + 1 ( 4-4-0 ) ( 3 -3 -5 ) ( 0-2-0-5 )
    • You could try posting a log (if there is no log at all, it may be the launcher you are using, the FAQ may have info on how to enable the log) as described in the FAQ, however this will probably need to be reported to/remedied by the mod author.
    • So me and a couple of friends are playing with a shitpost mod pack and one of the mods in the pack is corail tombstone and for some reason there is a problem with it, where on death to fire the player will get kicked out of the server and the tombstone will not spawn basically deleting an entire inventory, it doesn't matter what type of fire it is, whether it's from vanilla fire/lava, or from modded fire like ice&fire/lycanites and it's common enough to where everyone on the server has experienced at least once or twice and it doesn't give any crash log. a solution to this would be much appreciated thank you!
    • It is 1.12.2 - I have no idea if there is a 1.12 pack
  • Topics

×
×
  • Create New...

Important Information

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