Jump to content

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


sunsigne

Recommended Posts

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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

    • Slot depo 5k merupakan situs slot depo 5k yang menyediakan slot minimal deposit 5rb atau 5k via dana yang super gacor, dimana para pemain hanya butuh modal depo sebesar 5k untuk bisa bermain di link slot gacor thailand terbaru tahun 2024 yang gampang menang ini.   DAFTAR & LOGIN AKUN PRO SLOT DEPO 5K ⭐⭐⭐ KLIK DISINI ⭐⭐⭐  
    • Slot deposit 3000 adalah situs slot deposit 3000 via dana yang super gacor dimana para pemain dijamin garansi wd hari ini juga hanya dengan modal receh berupa deposit sebesar 3000 baik via dana, ovo, gopay maupun linkaja untuk para pemain pengguna e-wallet di seluruh Indonesia.   DAFTAR & LOGIN AKUN PRO SLOT DEPOSIT 3000 ⭐⭐⭐ KLIK DISINI ⭐⭐⭐  
    • OLXTOTO: Menikmati Sensasi Bermain Togel dan Slot dengan Aman dan Mengasyikkan Dunia perjudian daring terus berkembang dengan cepat, dan salah satu situs yang telah menonjol dalam pasar adalah OLXTOTO. Sebagai platform resmi untuk permainan togel dan slot, OLXTOTO telah memenangkan kepercayaan banyak pemain dengan menyediakan pengalaman bermain yang aman, adil, dan mengasyikkan. DAFTAR OLXTOTO DISINI <a href="https://imgbb.com/"><img src="https://i.ibb.co/GnjSVpx/daftar1-480x480.webp" alt="daftar1-480x480" border="0" /></a> Keamanan Sebagai Prioritas Utama Salah satu aspek utama yang membuat OLXTOTO begitu menonjol adalah komitmennya terhadap keamanan pemain. Dengan menggunakan teknologi enkripsi terkini, situs ini memastikan bahwa semua informasi pribadi dan keuangan para pemain tetap aman dan terlindungi dari akses yang tidak sah. Beragam Permainan yang Menarik Di OLXTOTO, pemain dapat menemukan beragam permainan yang menarik untuk dinikmati. Mulai dari permainan klasik seperti togel hingga slot modern dengan fitur-fitur inovatif, ada sesuatu untuk setiap selera dan preferensi. Grafik yang memukau dan efek suara yang mengagumkan menambah keseruan setiap putaran. Peluang Menang yang Tinggi Salah satu hal yang paling menarik bagi para pemain adalah peluang menang yang tinggi yang ditawarkan oleh OLXTOTO. Dengan pembayaran yang adil dan peluang yang setara bagi semua pemain, setiap taruhan memberikan kesempatan nyata untuk memenangkan hadiah besar. Layanan Pelanggan yang Responsif Tim layanan pelanggan OLXTOTO siap membantu para pemain dengan setiap pertanyaan atau masalah yang mereka hadapi. Dengan layanan yang ramah dan responsif, pemain dapat yakin bahwa mereka akan mendapatkan bantuan yang mereka butuhkan dengan cepat dan efisien. Kesimpulan OLXTOTO telah membuktikan dirinya sebagai salah satu situs terbaik untuk penggemar togel dan slot online. Dengan fokus pada keamanan, beragam permainan yang menarik, peluang menang yang tinggi, dan layanan pelanggan yang luar biasa, tidak mengherankan bahwa situs ini telah menjadi pilihan utama bagi banyak pemain. Jadi, jika Anda mencari pengalaman bermain yang aman, adil, dan mengasyikkan, jangan ragu untuk bergabung dengan OLXTOTO hari ini dan rasakan sensasi kemenangan!
    • Slot deposit dana adalah situs slot deposit dana yang juga menerima dari e-wallet lain seperti deposit via dana, ovo, gopay & linkaja terlengkap saat ini, sehingga para pemain yang tidak memiliki rekening bank lokal bisa tetap bermain slot dan terbantu dengan adanya fitur tersebut.   DAFTAR & LOGIN AKUN PRO SLOT DEPOSIT DANA ⭐⭐⭐ KLIK DISINI ⭐⭐⭐  
    • Slot deposit dana adalah situs slot deposit dana minimal 5000 yang dijamin garansi super gacor dan gampang menang, dimana para pemain yang tidak memiliki rekening bank lokal tetap dalam bermain slot dengan melakukan deposit dana serta e-wallet lainnya seperti ovo, gopay maupun linkaja lengkap. Agar para pecinta slot di seluruh Indonesia tetap dapat menikmati permainan tanpa halangan apapun khususnya metode deposit, dimana ketersediaan cara deposit saat ini yang lebih beragam tentunya sangat membantu para pecinta slot.   DAFTAR & LOGIN AKUN PRO SLOT DEPOSIT DANA ⭐⭐⭐ KLIK DISINI ⭐⭐⭐  
  • Topics

×
×
  • Create New...

Important Information

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