Jump to content

Recommended Posts

Posted

i fixed my problem, i somehow had the same information in 2 seperate classes , one class was passing 0 to all items, and the other class was setting an int to the items i was trying to add a burnvalue to.

 

ive gotten rid of the portion of code which makes all items have a value of 0 and now im able to add any item or block.

i ended up making an interfce to hold some int values for me so i can easily add the burn values without me doing a lot of maths in my head

public interface FuelHelperVariables
{
    //int burn values because mathsss
    int nein = 1;//burn val 1
    int eighth = nein*25;//burn val 25
    int quarter = eighth*2;//burn val 50
    int stick = quarter*2;//burn val 100
    int one = stick*2;//burn val 200 normal furnace, 1item smelted
    int coal = one*8;//burn val 1600
    int qs = coal*2;//burn val 3200 this is also the value for charkite
    int hs = qs*2;//burn val 6400
    int st = hs*2;//burn val 12800 whole stack

    //block burn values
    int block9 = coal*9;//burn val 14400
    int block4 = coal*4;//burn val
}

the chestplate is made with 8 charkite ingots, each ingot is double the value of coal so its set to qs*8 which is 25600
while my tools for this fuel are going to be special
charkite axe returns qs*8+one //this is adding the ingots and sticks together for a burn value

 

 

Posted
2 minutes ago, reapersremorse said:

i fixed my problem, i somehow had the same information in 2 seperate classes , one class was passing 0 to all items, and the other class was setting an int to the items i was trying to add a burnvalue to.

 

ive gotten rid of the portion of code which makes all items have a value of 0 and now im able to add any item or block.

i ended up making an interfce to hold some int values for me so i can easily add the burn values without me doing a lot of maths in my head


public interface FuelHelperVariables
{
    //int burn values because mathsss
    int nein = 1;//burn val 1
    int eighth = nein*25;//burn val 25
    int quarter = eighth*2;//burn val 50
    int stick = quarter*2;//burn val 100
    int one = stick*2;//burn val 200 normal furnace, 1item smelted
    int coal = one*8;//burn val 1600
    int qs = coal*2;//burn val 3200 this is also the value for charkite
    int hs = qs*2;//burn val 6400
    int st = hs*2;//burn val 12800 whole stack

    //block burn values
    int block9 = coal*9;//burn val 14400
    int block4 = coal*4;//burn val
}

the chestplate is made with 8 charkite ingots, each ingot is double the value of coal so its set to qs*8 which is 25600
while my tools for this fuel are going to be special
charkite axe returns qs*8+one //this is adding the ingots and sticks together for a burn value

 

 

why is this an interface??

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
Just now, reapersremorse said:

because im just testing, its literally just holding information to use in other classes

so why is it an interface? I would expect the values to be in a reference class as constants

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

if im not mistaken, a constant has to be passed again to declair it as either an int, double, float or other values. if im wrong, i could always change my code if it will work better than declairing variables in an interface that can be used in any class i add, also i can add more than just variables for math.

Posted
3 hours ago, reapersremorse said:

honestly i just wanted to see how useable it would be. it works the same and its less code.

Please don't. This should be a static class, like Math is.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
4 hours ago, Draco18s said:

Please don't. This should be a static class, like Math is.

Sorry but i don't see what i did wrong. 

I was planning to make a class dedicated to my functions and variables. But this seems so much easier to use. Will this interface cause issues in the future if i keep using it?

Posted
27 minutes ago, reapersremorse said:

Sorry but i don't see what i did wrong. 

I was planning to make a class dedicated to my functions and variables.

That's called a static class

27 minutes ago, reapersremorse said:

But this seems so much easier to use. Will this interface cause issues in the future if i keep using it?

Interfaces are not storage places for data. They're description templates that get implemented: they tell you what another object looks like without actually being the object.

  • Like 1
  • Thanks 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

My bad. I had bad information. Ill change it up when i get home.

 

Im not near my pc,

Could i use a constant to set different values for a random number??

I want to make an item that has a random durability/max uses every time its crafted.

Im planning to add part casts and molds and i want to make them use 1 durability on every craft but have a random number attached every time its crafted or repaired.

Could i use this type of information???

 

Public static final int[] RAND_DURA = new int[]{8,16,32,64,128,256};

 

Ive never messed with random int values before.

Posted
5 hours ago, reapersremorse said:

My bad. I had bad information. Ill change it up when i get home.

 

Im not near my pc,

Could i use a constant to set different values for a random number??

I want to make an item that has a random durability/max uses every time its crafted.

Im planning to add part casts and molds and i want to make them use 1 durability on every craft but have a random number attached every time its crafted or repaired.

Could i use this type of information???

 

Public static final int[] RAND_DURA = new int[]{8,16,32,64,128,256};

 

Ive never messed with random int values before.

Just do min_durability + ((max_durability - min_durability) * new Random.nextFloat(1))

 

This generates a random durability greater than or equal to min_durability and less than or equal to max_durability

  • Like 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)
2 minutes ago, Cadiboo said:

Just do min_durability + ((max_durability - min_durability) * new Random.nextFloat(1))

 

This generates a random durability greater than or equal to min_durability and less than or equal to max_durability

Or he could do

new Random().nextInt(max-min) + min + 1;

 

Edited by Animefan8888
  • Like 1

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
1 minute ago, Animefan8888 said:

Or he could do


new Random().nextInt(max-min) + min + 1;

 

Or that, but the first approach is easier to understand and read which is what I was aiming for. In actual code this method should be used, but I would probably wrap it in a method for readability

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

thank you both, i understand most of this.

thank you for the description, im kind of an idiot XD so this helps me more than you know.

1 hour ago, Cadiboo said:

Just do min_durability + ((max_durability - min_durability) * new Random.nextFloat(1))

 

This generates a random durability greater than or equal to min_durability and less than or equal to max_durability

 

1 hour ago, Animefan8888 said:

Or he could do


new Random().nextInt(max-min) + min + 1;

 

im gonna try to mess with this when i get home.

Posted

how is this?
i believe i did this right, now to implement this class in all my other classes.
i still need to add the common Strings,Floats,ints and doubles that my mod uses.

BTW: sorry if the color scheme is weird for you. i edited all my editor colors to more suit my crazy mind.

public final class Constants
{
    //int burn values because mathsss
    public static final int nein = 1;//burn val 1
    public static final int eighth = nein*25;//burn val 25
    public static final int quarter = eighth*2;//burn val 50
    public static final int stick = quarter*2;//burn val 100
    public static final int one = stick*2;//burn val 200 normal furnace, 1item smelted
    public static final int coal = one*8;//burn val 1600
    public static final int qs = coal*2;//burn val 3200 also charkite base value
    public static final int hs = qs*2;//burn val 6400
    public static final int st = 12800;//burn val 12800 whole stack

    //block burn values
    public static final int block9 = coal*9;//burn val 14400
    public static final int block4 = coal*4;//burn val
    public static final int Cblock9 = block9*2;//charkite block 9 ingots
    public static final int Cblock4 = block4*2;//charkite block 4 ingots

    //durability values
    public static final int MAXINT = 2147483647; //do not go past this limit
    public static final int MAXSAFEINT = 2000000000;//Max Durability for items and tools
    public static final int MAXDEVIDE = 200000000; // the number that should be the upper limit for any base things
    //used for random durability on spacific items
    public static final int MAXDURA = 8192;//Max int for durability
    public static final int MINDURA = 8;//Min durability for items and tools
    public static final int RANDURA = new Random().nextInt(MAXDURA-MINDURA)+MINDURA+1;


    //not in use yet
    //public constants for hopeful gui stuff in my manual
    public static final boolean YES = true; //confirm
    public static final boolean NO = false;//deny
    public static final boolean SUCCESS = true;//it worked
    public static final boolean FAILURE = false;//it failed
    public static final int INFINATE = -1;//infinate or not breakable value
    public static final String NEW_LINE = System.getProperty("line.separator"); //forces to another line
    public static final String FILE_SEPARATOR = System.getProperty("file.separator");
    public static final String PATH_SEPARATOR = System.getProperty("path.separator");
    public static final String EMPTY_STRING = "";//space without an actual space
    public static final String SPACE = " ";//space between words and such
    public static final String TAB = "\t";//tabs over in the text
    public static final String SINGLE_QUOTE = "'";
    public static final String PERIOD = ".";
    public static final String DOUBLE_QUOTE = "\"";

    // private constants
    private Constants()
    {
        throw new AssertionError();//just testing the private stuffs
    }
}

im no longer using the interface, im just importing this class

import static com.reapersremorse.uto.util.handlers.Constants.*;

 and i can use everything in the class without needing to import every value i use manually.

i may start putting all my variables and over used functions in this class.

Posted

Great!

This

new Random().nextInt(MAXDURA-MINDURA)+MINDURA+1;

should be in your ItemStack init or whatever constructers. not as a constant - do you want a constant value for "randomness"

11 minutes ago, reapersremorse said:

i may start putting all my variables and over used functions in this class.

I recommend following Minecraft's example and putting it in a class called Util(s)

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
4 minutes ago, Cadiboo said:

I recommend following Minecraft's example and putting it in a class called Util(s)

In this case Constants makes more sense. Utils implies there would be a functional application of the class ie methods, but this class only contains Constants. Though this is ultimately a personal choice like putting an I in front of an interface.

 

16 minutes ago, reapersremorse said:

public static final int MAXSAFEINT = 2000000000;//Max Durability for items and tools

I am unsure of this value, due to minecraft truncating there metadata value to 2 bytes aka a Short.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
1 minute ago, Animefan8888 said:

In this case Constants makes more sense. Utils implies there would be a functional application of the class ie methods, but this class only contains Constants. Though this is ultimately a personal choice like putting an I in front of an interface.

 

18 minutes ago, reapersremorse said:

over used functions in this class.

 

I quoted a little too much

 

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
2 minutes ago, Cadiboo said:

I quoted a little too much

My bad, I didn't see that small but of text at the very bottom of his post and didn't read the quote. In which case yes a class called Utils or two classes Utils and Constants would be fine.

  • Thanks 1

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
8 minutes ago, Cadiboo said:

should be in your ItemStack init or whatever constructers. not as a constant - do you want a constant value for "randomness"

lol i wasnt thinking, that would be useless and most useful at the same time. thanks ill fix that

 

8 minutes ago, Cadiboo said:

I recommend following Minecraft's example and putting it in a class called Util(s)

ive been using a util folder(package) and then adding all my over used stuff in there.

 

3 minutes ago, Animefan8888 said:

In this case Constants makes more sense. Utils implies there would be a functional application of the class ie methods, but this class only contains Constants. Though this is ultimately a personal choice like putting an I in front of an interface.

ive always done things different than others...
 

 

3 minutes ago, Animefan8888 said:

I am unsure of this value, due to minecraft truncating there metadata value to 2 bytes aka a Short.

i was basing it off of max int, i just do not wanna accidentally create memory leaks or crash the game by going over max int, that 2Billion number is for the max number i would like to use as an int and its 10X more than anything that im ever going to add because of certain ideas i have for the future ;>

Posted (edited)
2 minutes ago, reapersremorse said:

i was basing it off of max int, i just do not wanna accidentally create memory leaks or crash the game by going over max int, that 2Billion number is for the max number i would like to use as an int and its 10X more than anything that im ever going to add because of certain ideas i have for the future ;>

He was saying that the actual max value is smaller because the data is not an integer, its a short. 

Integer (signed) is between -(2^31) and (2^31)-1

Short (signed) is between -(2^15) and (2^15)-1

http://www.tocker.ca/2014/05/30/how-important-is-it-to-use-2-byte-and-3-byte-integers.html

Edited by Cadiboo
  • 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
2 minutes ago, reapersremorse said:

if this is true, how do other mods use this number as their max in, like ee3/projecte and any mod that add energy storage??

sorry?

Mojang decided that they wanted shorts for their damage values. not all integers are shorts. if your looking for the highest possible value for an integer it is Integer.MAX_VALUE

 

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
1 minute ago, reapersremorse said:

if this is true, how do other mods use this number as their max in, like ee3/projecte and any mod that add energy storage??

As far as I know they dont use the damage value directly they use NBT data to store a full sized integer and then create a fraction min/max and multiply that by the actual max damage.

 

So say we have a tool that has a durability of 40,000. And it currently has 20,000 left. And the max damage the item can have is 100. So 20,000/40,000 is. 5 or 50%. Then we multiply .5 by 100 and get 50. So our damage value is 50, but our actual durability is 20,000.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

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




×
×
  • Create New...

Important Information

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