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

    • 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 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.