Jump to content

Add type Long to Properties


Neometron

Recommended Posts

Hi, I working on my mod called AdvanceTime, and Minecraft stores its ticks in type long. I added this code into my project, however I would like to see this in Forge.

 

[net.minecraftforge.common - Properties.java]

 

public enum Type
    {
        STRING,
        INTEGER,
        BOOLEAN,
        DOUBLE,
        LONG;
...

 

/**
     * Returns the value in this property as an long,
     * if the value is not a valid long, it will return the
     * provided default.
     * 
     * @param _default The default to provide if the current value is not a valid long
     * @return The value
     */
    public long getLong(long _default)
    {
        try
        {
            return Long.parseLong(value);
        }
        catch (NumberFormatException e)
        {
            return _default;
        }
    }
    
    /**
     * Checks if the current value stored in this property can be converted to an long.
     * 
     * @return True if the type of the Property is an long
     */
    public boolean isLongValue()
    {
        try
        {
            Long.parseLong(value);
            return true;
        }
        catch (NumberFormatException e)
        {
            return false;
        }
    }

 

Also for the config file, I would like to to "L" instead of "D"

 

VR:

Neometron

Link to comment
Share on other sites

  • 2 months later...
  • 5 months later...

I forgot about this old post, but AdvanceTime is released and it justify updating.

 

Longs are just two ints.

Yes, but that was not what I was requesting.

I basically gave the code; why make mod developers dance around this one property type when it should be part of Forge?

 

you can't parse your own long? because it looks like forge offers string config types.

Yes, this is what I ended up doing ;) However, why should I? Getting values from all other property types is pretty and clean, except when it comes to parsing longs with try-catch everywhere.

 

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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