Jump to content

[1.12.2][SOLVED] Double Crop Blockstate Update


Boy132

Recommended Posts

Hey,

 

I want to create a double block crop (corn) but the top blockstate isn't updating. (see the screenshots: https://imgur.com/a/ndTM2jk)

 

https://pastebin.com/wvb0X6L5

https://pastebin.com/GcENDYY3

https://pastebin.com/hxVhr473

 

The setBlockState methods return true and the "input" blockstate is correct but the age of the crop is not updated. (also WAILA says that the bottom crop is always "mature" even it's not?)

 

EDIT: Okay, "natural" growing works fine. Using bonemeal causes this problem but I still don't know why.

Edited by Boy132
solved :)
Link to comment
Share on other sites

This is not functionally useful. If the chunk the crop is in is not loaded, then the crop won't update. The blocks above the crop are always in the same chunk as the crop itself.

 

        if(!world.isAreaLoaded(pos, 1))
            return; // Forge: prevent loading unloaded chunks when checking neighbor's light
 
Nice to see you including the crop grow events
 
if(ForgeHooks.onCropsGrowPre(world, pos, state, rand.nextInt((int) (25.0F / f) + 1) == 0))
 
Dollars to doughnuts this line isn't doing what you want:
 
int i = getAge(state);

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

I copied the chunk loading check and the grow events check from the BlockCrops class. :)

 

getAge is from the super class BlockCrops:

protected int getAge(IBlockState state)
{
    return ((Integer)state.getValue(this.getAgeProperty())).intValue();
}

And this does work, normal growing (updateTick) kind of works but when I use bonemeal (grow) on the lower half the upper one gets not updated.

Edited by Boy132
Link to comment
Share on other sites

Yes, and what I'm saying is, your two-block crop isn't using one block to store its age. Its using two. That method can't deal with that.

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

But I'm doing all of the logic only if it's the lower half and then update both.

Also that doesn't explain why the updateTick method works but the grow method not. (both use the same getAge and only execute on the lower half)

Link to comment
Share on other sites

By the way:

if(false && !world.isRemote) // Forge: NOP all this.

 

Why do you still have that block it does nothing?

 

Its also a terrible idea to use +10 as your UPPER/LOWER value. Metadata is limited by 16 states, meaning you're limiting your max age to 6, whereas if you used a single bit (+8) you could have max ages up to 8. It also means you can use bitwise logic instead (int age = meta & 7; int halfAsInt = meta & 8).

 

this.seed = new CoreSeedFood(name, 3, this);

 

You can't do this. You are not allowed to create items at this point in the startup process. How do you even register this item?

 

Quote

The setBlockState methods return true

The return value from setBlock is not useful in any capacity that I've ever seen.

 

And after a lot of testing, I've determined the issue. This function is run when you use bonemeal:

 

    @Override
    public void onBlockAdded(World world, BlockPos pos, IBlockState state)
    {
        if(getHalf(state) == EnumCropHalf.LOWER)
            world.setBlockState(pos.up(), getDefaultState().withProperty(HALF, EnumCropHalf.UPPER), 2);
    }

 

It does not run when the block updates.

Edited by Draco18s
  • 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

12 hours ago, Draco18s said:

By the way:

if(false && !world.isRemote) // Forge: NOP all this.

 

Why do you still have that block it does nothing?

You're right, I removed this part. :)

 

12 hours ago, Draco18s said:

Its also a terrible idea to use +10 as your UPPER/LOWER value. Metadata is limited by 16 states, meaning you're limiting your max age to 6, whereas if you used a single bit (+8) you could have max ages up to 8. It also means you can use bitwise logic instead (int age = meta & 7; int halfAsInt = meta & 8).

Haven't thought so much about it but I changed this too.

 

12 hours ago, Draco18s said:

this.seed = new CoreSeedFood(name, 3, this);

 

You can't do this. You are not allowed to create items at this point in the startup process. How do you even register this item?

Why can't I do this? I add all my Blocks/ Items to Lists in my Init classes and then iterate through these lists in the registry events - and it works. :D

 

12 hours ago, Draco18s said:

And after a lot of testing, I've determined the issue. This function is run when you use bonemeal:

 


    @Override
    public void onBlockAdded(World world, BlockPos pos, IBlockState state)
    {
        if(getHalf(state) == EnumCropHalf.LOWER)
            world.setBlockState(pos.up(), getDefaultState().withProperty(HALF, EnumCropHalf.UPPER), 2);
    }

 

It does not run when the block updates.

Ahhh thank you very much! I changed the if to

if(getHalf(state) == EnumCropHalf.LOWER && getAge(state) == 0)

and now it works.

 

Just one little question: do you now why HWYLA shows that the lower part is "mature" (even if it's not). The upper part is shown correctly and other "normal" crops are correct too?

Link to comment
Share on other sites

8 hours ago, Boy132 said:

Why can't I do this? I add all my Blocks/ Items to Lists in my Init classes and then iterate through these lists in the registry events - and it works. :D

All of them except your seed, which unless you add it to those lists in the constructor (terrible idea).

 

8 hours ago, Boy132 said:

do you now why HWYLA shows that the lower part is "mature" (even if it's not). The upper part is shown correctly and other "normal" crops are correct too?

No. Probably because its using the default crop inspector, which is mature if the metadata value >= 7. You'll have to write your own inspector is my guess.

  • 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

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

    • Baba  Serege [[+27-73 590 8989]] has experience of 27 years in helping and guiding many people from all over the world. His psychic abilities may help you answer and resolve many unanswered questions. He specialize in helping women and men from all walks of life.. 1) – Bring back lost lover. even if lost for a long time. 2) – My lover is abusing alcohol, partying and cheating on me I urgently need help” 3) – Divorce or court issues. 4) – Is your love falling apart? 5) – Do you want your love to grow stronger? 6) – Is your partner losing interest in you? 7) – Do you want to catch your partner cheating on you? – We help to keep your partner faithful and loyal to you. 9) – We recover love and happiness when relationship breaks down. 10) – Making your partner loves you alone. 11) – We create loyalty and everlasting love between couples. 12) – Get a divorce settlement quickly from your ex-partner. 13) – We create everlasting love between couples. 14) – We help you look for the best suitable partner. 15) – We bring back lost lover even if lost for a long time. 16) – We strengthen bonds in all love relationship and marriages 17) – Are you an herbalist who wants to get more powers? 18) – Buy a house or car of your dream. 19) – Unfinished jobs by other doctors come to me. 20) – I help those seeking employment. 21) – Pensioners free treatment. 22) – Win business tenders and contracts. 23) – Do you need to recover your lost property? 24) – Promotion at work and better pay. 25) – Do you want to be protected from bad spirits and nightmares? 26) – Financial problems. 27) – Why you can’t keep money or lovers? 28) – Why you have a lot of enemies? 29) – Why you are fired regularly on jobs? 30) – Speed up money claim spell, delayed payments, pension and accident funds 31) – I help students pass their exams/interviews. 33) – Removal of bad luck and debts. 34) – Are struggling to sleep because of a spiritual wife or husband. 35- ) Recover stolen property
    • OLXTOTO adalah situs bandar togel online resmi terbesar dan terpercaya di Indonesia. Bergabunglah dengan OLXTOTO dan nikmati pengalaman bermain togel yang aman dan terjamin. Koleksi toto 4D dan togel toto terlengkap di OLXTOTO membuat para member memiliki pilihan taruhan yang lebih banyak. Sebagai situs togel terpercaya, OLXTOTO menjaga keamanan dan kenyamanan para membernya dengan sistem keamanan terbaik dan enkripsi data. Transaksi yang cepat, aman, dan terpercaya merupakan jaminan dari OLXTOTO. Nikmati layanan situs toto terbaik dari OLXTOTO dengan tampilan yang user-friendly dan mudah digunakan. Layanan pelanggan tersedia 24/7 untuk membantu para member. Bergabunglah dengan OLXTOTO sekarang untuk merasakan pengalaman bermain togel yang menyenangkan dan menguntungkan.
    • Baba  Serege [[+27-73 590 8989]] has experience of 27 years in helping and guiding many people from all over the world. His psychic abilities may help you answer and resolve many unanswered questions. He specialize in helping women and men from all walks of life.. 1) – Bring back lost lover. even if lost for a long time. 2) – My lover is abusing alcohol, partying and cheating on me I urgently need help” 3) – Divorce or court issues. 4) – Is your love falling apart? 5) – Do you want your love to grow stronger? 6) – Is your partner losing interest in you? 7) – Do you want to catch your partner cheating on you? – We help to keep your partner faithful and loyal to you. 9) – We recover love and happiness when relationship breaks down. 10) – Making your partner loves you alone. 11) – We create loyalty and everlasting love between couples. 12) – Get a divorce settlement quickly from your ex-partner. 13) – We create everlasting love between couples. 14) – We help you look for the best suitable partner. 15) – We bring back lost lover even if lost for a long time. 16) – We strengthen bonds in all love relationship and marriages 17) – Are you an herbalist who wants to get more powers? 18) – Buy a house or car of your dream. 19) – Unfinished jobs by other doctors come to me. 20) – I help those seeking employment. 21) – Pensioners free treatment. 22) – Win business tenders and contracts. 23) – Do you need to recover your lost property? 24) – Promotion at work and better pay. 25) – Do you want to be protected from bad spirits and nightmares? 26) – Financial problems. 27) – Why you can’t keep money or lovers? 28) – Why you have a lot of enemies? 29) – Why you are fired regularly on jobs? 30) – Speed up money claim spell, delayed payments, pension and accident funds 31) – I help students pass their exams/interviews. 33) – Removal of bad luck and debts. 34) – Are struggling to sleep because of a spiritual wife or husband. 35- ) Recover stolen property
    • BD303 merupakan salah satu situs slot mudah scatter paling populer dan digemari oleh kalangan slot online di tahun 2024 mainkan sekarang dengan kesempatan yang mudah menang jackpot jutaan rupiah.
  • Topics

×
×
  • Create New...

Important Information

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