Jump to content

[1.12.2] turn Itemstack into Itemstack [ ] [Solved]


Recommended Posts

Posted (edited)

Hi :)

 

I almost finished my multi-output furnace, but i have one missing step. I need to turn

 

this :

Spoiler

public ItemStack getCentrifugeResult(ItemStack input) 
    {
        for (Entry<ItemStack, ItemStack> entry : this.smeltingList.entrySet())
        {
            if (this.compareItemStacks(input, entry.getKey()))
            {
                return entry.getValue();
            }
        }

        return ItemStack.EMPTY;
    }

 

 

into this :

Spoiler

public ItemStack [] getCentrifugeResult(ItemStack input) 
    {
        for (Entry<ItemStack, ItemStack[]> entry : this.smeltingList.entrySet())
        {
            if (this.compareItemStacks(input, entry.getKey()))
            {
                return entry.getValue();
            }
        }

        return ??????????
    }

 

Any idea of an equivalent ?

 

Thanks for reading :) 

 

 

 

 

 

To help, here is a working equivalent I made up

 

this:

Spoiler

ItemStack result = EnchantedRecipes.getInstance().getEnchantedResult(this.itemStackHandler.getStackInSlot(0));    
                
                if(result.isEmpty()) return false;

 

give this :

Spoiler

ItemStack [] result = CentrifugeRecipes.getInstance().getCentrifugeResult(this.itemStackHandler.getStackInSlot(0));    
            
            if(result[0].isEmpty() || result[1].isEmpty() || result[2].isEmpty() || result[3].isEmpty() || result[4].isEmpty()) return false;

 

Edited by sunsigne
solved
Posted

You should use a NonNullList (as array values are allowed to be null), but new ItemStack[]{} will create an empty array.

  • 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 (edited)
6 hours ago, Draco18s said:

You should use a NonNullList (as array values are allowed to be null), but new ItemStack[]{} will create an empty array.

 

Thanks ! That'a a clever trick to solve the problem ;) but now i have another problem ^^ i thought i could copy-paste the solution-code because it was the same thing, but it looks like it's slightly different. 

 

Earlier, i have this :

if(getEnchantedResult(input) != ItemStack.EMPTY) return;

 

But it looks like i can't translate it this way :

if(getEnchantedResult(input) !=(ItemStack[]{}) return;

 

Any suggestion ?

 

It's okay if you haven't any, you already did a lot for me

Edited by sunsigne
Posted
10 hours ago, sunsigne said:

if(getEnchantedResult(input) !=(ItemStack[]{}) return;

What is this

you need to check if it is empty by checking the values or all the stacks. This can be accomplished with streams or loops.

You also shouldn’t compare with ItemStack.EMPTY. Use ItemStack#isEmpty

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

What is this

you need to check if it is empty by checking the values or all the stacks. This can be accomplished with streams or loops.

You also shouldn’t compare with ItemStack.EMPTY. Use ItemStack#isEmpty

 

Yeah, now it works ^^ thank :)

Posted (edited)
17 hours ago, sunsigne said:

But it looks like i can't translate it this way :

if(getEnchantedResult(input) !=(ItemStack[]{}) return;

getEnchantedResult(input).length == 0?

Its an array. Stop being dumb.

Edited by Draco18s

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 (edited)
2 hours ago, Draco18s said:

Its an array. Stop being dumb.

 

No need to be rude. Maybe it's obvious for you what an "array" is because you've been codding for years, but all this stuff may be new for people who started 3 weeks ago. As i do my best to understand what you all say i find your comment completly unfair ! It's not like if i wasn't trying to fix a problem by my own first before posting. I usually spend a couple of hour before asking for help.

 

I'm not calling you "jerk" as your citation says, but you can't pretend you have just trying to be nice very right now.

Edited by sunsigne
Posted

You obviously knew what an array was before you posted, which meant you should have known what member properties if had. 

 

Unless you're going to tell me that you "did ItemStack[] because someone else did it and you didn't know what it meant."

 

If you do, then I'll say that you are dumb, instead of just acting like it. Because that's how cargo cults are started and you shouldn't be modding yet. 

2 hours ago, sunsigne said:

people who started 3 weeks ago

I take that back. You do need to go learn how to program first. Modding is not a good way too learn, its a horrible idea because you copy what someone else did without being able to understand WHY they did it, and then they don't EXPLAIN why because they too have only just started! Blind leading the blind, the lot of you! 

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 (edited)

Why do you refuse to accept there is a middle between "not understanding at all what you are doing" and "completly fully understanding what you are doing" ? Life isn't that binary. That's why we rate at school.

 

I used ItemStack [ ] because i saw someone else does it, yes. But I searched that info on purpose because I wanted my object has these properties (multi output). I tried to adapt different codes I see to create my OWN objects with the properties i DECIDED they would had. If I don't find the info, i try random things which sounds good, taking inspirations from what I already did then I launch the game. If it crashes, i try to understand why, change my codes, re-try, ect... 

I first copy, then read and try to understand WHY those lines exists and what it does, then I understand what i need to change if I want something different.

 

 

Yes, it's not perfect, but i have kind of create a lot of cool stuff so long. My OWN stuff. Judge me if it pleases you, tell you friends how i'm a morron because I'm not a pro like you, i'll call you morron tommorow when you'll play guitar in front of me ^^ Sounds stupid right ?

 

I know i should learn codding in java if I want to create better stuff, but as long as I'm just a random man who wanted 2 or 3 cool things on the only game his wife aggree to play with, i assumed it should be ok if I just would do some research to adds those things. Codding isn't a passion for everyone, and I don't need it in my life (yet?). Why should I spends months and months to learn how to code properly just to play ONE song at a birthday's party, then never touch a guitar after that ? And my only one song (my mod, still a methaphor) is pretty great for the moment.

 

I respect your love for codding and I like passionate people. But you can't just call people dumb because they don't understand "some" things in your field. Why do you say "hello" ? Because everyone does ? Are you just copying people without thinking ? To cut a long story short : i do some stupid mistakes because I MANAGE to code while never codding before, but I actually think and re-think my code to make it works; and it does.

 

 

 

PS : I even spend 3 days just to refresh my code from IIventory (the tuto i followed used that) into IItemHandler (and there are really few infos about that) ONLY because you guys on this forum say it's better (the topic in proff is here) and I thought it was respecting your job. I do my best to respect you all, always politly, always following your advice, i even created a Guihub (what took me severeal hours because I didn't know how to do) just because someone asked me if I had one. As a total noob, i do my best to respect your job and not wasting your time : i wait TWO DAYS of perma fail codding before asking for help. The least you can do toward someone who tried that hard to respect you all is not to disrespect him ^^ (and don't tell me you aren't, "blind", "cargo cult", and "dumb" aren't especially neutral words when they are used to describe someone)

Edited by sunsigne
Posted
3 hours ago, sunsigne said:

Life isn't that binary.

 

school.png

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

Modding is a bad way to learn programming, as lots of stuff is done badly, many dirty hacks are used and you have to do a bunch of stuff in Avery specific way that is unique to modding

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)
9 hours ago, Draco18s said:

 

school.png

 

Sure, hide yourself behind citation instead of giving argue ^^ I told you I work hard to understand what I do not watsing your time. If you don't want to help people who don't succed to make them code work, why this forum exist so ? I did my part, but it looks like you only read the first line i wrote ^^

Ho, and isn't it expected to be polite and not insulting people on this forum too ? If it's not, i can begin to be mean too after all. If it is, well, you didn't respect that rule ^^

 

 

You want a real fact, here is it : your comment was mean, but instead of simply apologize and admit you were wrong to write that, you try to justify your behavior explaining why you were right. But first : I explained how I do my best and your judgement is unfair, and second : you NEVER can find a justification for being mean.

 

Ho, and don't misanderstand me : I said you comment was mean. I don't say you are, netheir you have been so far. We all do mistake and are harsh sometimes, but it's okay if we apologize. Not if we stuborn on belittle people ^^

 

 

6 hours ago, Cadiboo said:

Modding is a bad way to learn programming, as lots of stuff is done badly, many dirty hacks are used and you have to do a bunch of stuff in Avery specific way that is unique to modding

Totally agree, but as I said I'm not trying to learn playing guitar overall ;) only one song then I can forget it. And with the time I spend in learning correctly that specific song, it's unfair to just "sweep away with the back of the hand" my whole work :S You should listen to my song first ^^  (I'm not telling you are :) i'm talking about the other guy). But overall, i agree with what you say : with bad learning comes bad habbits.

 

Edited by sunsigne
GitHub link
Posted (edited)

I have no problem with learning java. I have a problem with people insulting me ^^ not the same. And i probably used a lot of arrayw into my code without knowing the name "array". I don't go foward blindly, i kind of understand what i'm doing for the most part ^^ did you watch my github before writting this ? I'm pretty sure someone who doesn't understand java at least a little can achive all the stuff i did.

 

I'm only here for very parts I don't success to understand alone after days of research, at that really a little part. So what ? I don't understand the word "array" so I don't deserve any help ? As i said I probably already get the principe but the word ^^ If you correctly play much of chors, I hell don't care you can't name them ! 

 

And if all people here 100% understand java adn modding, why are there here so ? Geez ! What's wrong with you two ? You keep judging me and my work while you didn't even watch it ! It's not even unfair, it's just nonsense

Edited by sunsigne
Posted

By the way,

= checks whether 2 references are the same reference (if 2 objects are the same instance)

.equals checks if 2 objects are equal

 

for example new String() == new String() will never be true. However new String().equals(new String()) will always be true

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)

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.