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

    • Hello! My friends and I were attempting to add a few extra mods to the Create Chronicles modpack, and all was well until people started crashing when they opened their inventories. Any help finding the culprit would be MUCH appreciated, I've been scratching my head for the past few days on what went wrong. https://paste.ee/p/8pajP
    • >>>KLIK LOGIN DISINI SAYANG<<< >>>KLIK DAFTAR DISINI SAYANG<<< Pendahuluan Dalam dunia perjudian online, slot menjadi salah satu permainan yang paling diminati. Dengan munculnya berbagai platform, Togel2Win hadir sebagai salah satu pilihan menarik, terutama dengan fitur anti rungkad yang dijanjikan. Artikel ini akan membahas tentang Togel2Win, keunggulan slot terbaru, dan bagaimana server Thailand berperan dalam meningkatkan pengalaman bermain. Apa Itu Togel2Win? Togel2Win adalah platform permainan yang menawarkan berbagai jenis permainan, termasuk slot dan togel. Dengan antarmuka yang ramah pengguna dan beragam pilihan permainan, situs ini bertujuan untuk memberikan pengalaman bermain yang menyenangkan dan menguntungkan bagi para pemain. Keunggulan Slot Togel2Win Fitur Anti Rungkad: Salah satu keunggulan utama dari Togel2Win adalah fitur anti rungkad yang dirancang untuk mengurangi kemungkinan gangguan saat bermain. Ini memastikan bahwa pemain dapat menikmati permainan tanpa gangguan teknis, meningkatkan kenyamanan dan fokus. Beragam Pilihan Slot: Togel2Win menawarkan berbagai jenis slot, dari yang klasik hingga yang modern dengan grafis menawan dan tema yang menarik. Ini memberikan variasi yang cukup bagi pemain untuk menemukan permainan yang sesuai dengan preferensi mereka. Server Thailand yang Stabil: Server yang berlokasi di Thailand memberikan koneksi yang cepat dan stabil. Ini sangat penting untuk pengalaman bermain yang lancar, terutama saat bermain slot yang memerlukan respons cepat. Bonus dan Promosi Menarik: Togel2Win sering menawarkan bonus dan promosi yang menarik untuk menarik pemain baru dan mempertahankan loyalitas pemain yang sudah ada. Ini bisa berupa bonus deposit, putaran gratis, atau program loyalitas. Tips untuk Pemain Slot di Togel2Win Pilih Slot dengan RTP Tinggi: Sebelum memulai permainan, pastikan untuk memilih slot dengan tingkat pengembalian pemain (RTP) yang tinggi untuk meningkatkan peluang menang. Kelola Anggaran: Tentukan batasan anggaran sebelum bermain dan patuhi itu. Ini membantu mencegah kerugian besar dan menjaga pengalaman bermain tetap menyenangkan. Manfaatkan Bonus: Jangan ragu untuk memanfaatkan bonus dan promosi yang ditawarkan. Ini bisa memberikan tambahan modal untuk bermain lebih lama. Kesimpulan Togel2Win merupakan pilihan menarik bagi para penggemar slot, terutama dengan fitur anti rungkad dan server yang stabil. Dengan berbagai pilihan permainan dan bonus yang menggiurkan, Togel2Win siap memberikan pengalaman bermain yang tak terlupakan. Jika Anda mencari platform slot yang andal dan menyenangkan, Togel2Win bisa menjadi solusi yang tepat.
    • I'm trying to make my own modpack, but sometimes, in certain areas of the world, the game just says "server closed". Minecraft doesn't close, it just returns to the menu. When I tried to figure it out on my own and understand the logs, I didn't understand anything (English is not my native language, so it's difficult for me). I've been trying to solve the problem for the third month. So I ask if anyone is good at this and it's not difficult for you, to help me with this. If you need details, ask. I'll describe everything. What it looks like Logs
  • Topics

×
×
  • Create New...

Important Information

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