Jump to content

[1.14.3] Looking for what replaced tick in Block.class


kwpugh

Recommended Posts

Hi All,

 

I'm looking for guidance.   I'm converting an item that ticks crops when held in main hand.   I had used the tick method in the Block.class.

 

Since it has been deprecated:


   @Deprecated
   public void tick(BlockState state, World worldIn, BlockPos pos, Random random) {
   }

 

Where should I be looking?

 

Thank you.

 

Link to comment
Share on other sites

Quote

Cross-referencing, a quick how-to

  • Oh no! Method FooClass.BarMethod disappeared in 1.13/1.14! Where did it go? Follow these easy steps for a guaranteed 80% success rate!
  1. Open a 1.12 workspace (this is why you use a separate workspace to update, by the way)
  2. Browse to FooClass.BarMethod
  3. Use your IDE's find usages tool to see where it was called from in vanilla
  4. Pick a call site
  5. Go to that same call site in 1.13/1.14
  6. What does it call instead?
  7. ???
  8. Profit

(if these steps don't apply, then you're allowed to ask)

 

  • Like 1
  • 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

If I'm looking at this right, it seem that the places updateTick was called from by vanilla have been replaced with animateTick, which does not work for accelerating block state transitions (not sure if I said that right).   

 

Basically, I want to be able to accelerate the ticks received by IGrowables in a defined block distance while my item is held in the main hand.

 

Any suggestions?

 

 

Link to comment
Share on other sites

Surely the wheat block has code that runs in some tick-like manner that is the code you want to call. Have you tried looking at the wheat block?

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

In digging around in the Minecraft references, I was able to figure out that the IGrowable interface controls the crops and saplings.

 

I was able to adapt my existing 1.12.2 code to work.  However, the effect is instant, which is not exactly what I want.

package com.kwpugh.gobber2.items.rings;

import java.util.List;

import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.IGrowable;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.world.World;

public class ItemCustomRingFarmer extends Item
{

	public ItemCustomRingFarmer(Properties properties)
	{
		super(properties);
	}

	public void inventoryTick(ItemStack stack, World world, Entity entity, int par4, boolean par5)
    {
        
    	if(!(entity instanceof PlayerEntity) || world.isRemote)
        {
            return;
        }

    	PlayerEntity player = (PlayerEntity)entity;
        ItemStack equipped = player.getHeldItemMainhand();
        
        if(stack == equipped)
        {
            int range = 7;
            for(int x = -range; x < range+1; x++)
            {
                for(int z = -range; z < range+1; z++)
                {
                    for(int y = -range; y < range+1; y++)
                    {
                        int theX = MathHelper.floor(player.posX+x);
                        int theY = MathHelper.floor(player.posY+y);
                        int theZ = MathHelper.floor(player.posZ+z);
                        
                        BlockPos posInQuestion = new BlockPos(theX, theY, theZ);
                        
                        BlockState blockstate = world.getBlockState(posInQuestion);
                        
                        if ((blockstate.getBlock() instanceof IGrowable))
                        {
                            IGrowable igrowable = (IGrowable)blockstate.getBlock();
                            
                            if((igrowable == Blocks.GRASS_BLOCK) ||
                            		(igrowable == Blocks.TALL_GRASS) ||
                            		(igrowable == Blocks.GRASS) ||
                            		(igrowable == Blocks.SUNFLOWER) || 
                            		(igrowable == Blocks.LILAC) || 
                            		(igrowable == Blocks.ROSE_BUSH) || 
                            		(igrowable == Blocks.PEONY) || 
                            		(igrowable == Blocks.SEAGRASS) ||
                            		(igrowable == Blocks.TALL_SEAGRASS))
                            {
                            	continue;
                            }
                            if (igrowable.canGrow(world, posInQuestion, blockstate, world.isRemote))
                            {
                                {
                                	if (!world.isRemote)
                                    {
                                		igrowable.grow(world, world.rand, posInQuestion, blockstate);
                                    }
                                }
                            }       
                        }
                    }
                }
            }
       }
    }
	
    @Override
	public void addInformation(ItemStack stack, World world, List<ITextComponent> list, ITooltipFlag flag)
	{
		super.addInformation(stack, world, list, flag);				
		list.add(new StringTextComponent("Works on: wheat, beetroot, carrot, potato, and tree saplings"));
		list.add(new StringTextComponent("Range: 14 blocks"));
		list.add(new StringTextComponent("Still a bit of a WIP"));
	}  
}

Oddly, the Sunflower, Lilac, Rose Buse, and Peony will constantly drop their ItemStack if I don't exclude them.

 

Can anyone provide some suggestions for writing a safe and proper timing method that can add a delay in the process?  I have seen reference to COOLDOWN in some of the minecraft references, is that a built-in method for that purpose?

 

Any guidance would be greatly appreciated.

 

Thank you and kind regards.

 

 

 

Link to comment
Share on other sites

3 hours ago, kwpugh said:

I have seen reference to COOLDOWN in some of the minecraft references, is that a built-in method for that purpose?

Corus fruit uses it. I believe it is an acceptable general use feature, yes.

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

Thank you for the suggestion, but frankly, I have  no idea what that means.  I'll do some research to see if I can figure it out.

 

Questions for clarification:

- by modulo, I presume you are talking about the remainder of the division of two numbers?

- the ticksExisted of the entity, where the "entity" is the plant or crop?

 

 

 

Link to comment
Share on other sites

17 hours ago, kwpugh said:

- by modulo, I presume you are talking about the remainder of the division of two numbers?

Yes. It is the % operator.

17 hours ago, kwpugh said:

- the ticksExisted of the entity, where the "entity" is the plant or crop?

Crops aren't entities, they're blocks. Plants are also crops and also blocks.

In this case you can use the Player as the entity in question.

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

Thank you for the clarification.

 

I found these examples in the reference code, that seem to control the rate that natural regeneration occurs:

    if (this.getHealth() < this.getMaxHealth() && this.ticksExisted % 20 == 0) {
            this.heal(1.0F);
         }

         if (this.foodStats.needFood() && this.ticksExisted % 10 == 0) {
            this.foodStats.setFoodLevel(this.foodStats.getFoodLevel() + 1);
         }

What I do not understand from looking at this is "what is ticksExisted" containing?  Is this a continuing count of the # of ticks the player entity has existed or something else?

 

I see the ticksExisted is an int variable declared in Entiy.java, but I do not understand what it is storing.  

 

Regards.

Link to comment
Share on other sites

So, through a little "trial-n-error" I was able to get a delay working.

 

if (igrowable.canGrow(world, tagetPos, blockstate, world.isRemote))
                            {
                                {
                                	if (!world.isRemote)
                                    {
                                		 if (player.ticksExisted % 60 == 0) {
                                			 igrowable.grow(world, world.rand, tagetPos, blockstate);
                                		 }
                                    }
                                }
                            } 

A value of 60 goes much slower, smaller numbers make it faster.  

 

Since I do not know what the value is stored in ticksExisted, it could just be luck.   I still would like to understand what that variable contains and how it works.

 

Regards.

 

Link to comment
Share on other sites

ticksExisted is a field that stores the number of ticks the entity has existed. It's...pretty self-documenting.

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

    • Detik4D adalah situs slot 4D resmi yang menawarkan pengalaman bermain yang mengasyikkan dan peluang menang besar. Dengan koleksi permainan slot yang beragam dan fitur-fitur menarik, Detik4D menjadi pilihan utama bagi para pecinta slot online. Peluang Menang Besar dengan Jackpot Resmi Salah satu keunggulan utama Detik4D adalah peluang menang besar yang ditawarkan. Dengan sistem jackpot resmi, para pemain memiliki kesempatan untuk memenangkan hadiah besar yang dapat mengubah hidup mereka. Jackpot-jackpot ini tidak hanya menghadirkan keseruan tambahan dalam bermain, tetapi juga memberikan peluang nyata untuk meraih keuntungan yang signifikan. Detik4D juga memiliki berbagai macam permainan slot dengan tingkat pembayaran yang tinggi. Dengan demikian, peluang untuk meraih kemenangan dalam jumlah besar semakin terbuka lebar. Para pemain dapat memilih dari berbagai jenis permainan slot yang menarik, termasuk slot klasik, video slot, dan slot progresif. Setiap jenis permainan memiliki fitur-fitur unik dan tema yang berbeda, sehingga para pemain tidak akan pernah merasa bosan. Pengalaman Bermain yang Mengasyikkan Selain peluang menang besar, Detik4D juga menawarkan pengalaman bermain yang mengasyikkan. Dengan tampilan grafis yang menarik dan suara yang menghibur, para pemain akan merasa seperti berada di kasino sungguhan. Fitur-fitur interaktif seperti putaran bonus, putaran gratis, dan fitur-fitur lainnya juga akan menambah keseruan dalam bermain. Detik4D juga memiliki antarmuka yang user-friendly, sehingga para pemain dapat dengan mudah mengakses permainan dan fitur-fitur lainnya. Proses pendaftaran dan deposit juga sangat mudah dan cepat, sehingga para pemain dapat segera memulai petualangan mereka di dunia slot online. Detik4D juga menyediakan layanan pelanggan yang responsif dan profesional. Tim dukungan pelanggan yang ramah akan siap membantu para pemain dengan segala pertanyaan atau masalah yang mereka hadapi. Dengan demikian, para pemain dapat bermain dengan tenang dan yakin bahwa mereka akan mendapatkan bantuan yang mereka butuhkan. Keamanan dan Kepercayaan Detik4D sangat memprioritaskan keamanan dan kepercayaan para pemain. Situs ini menggunakan teknologi enkripsi terkini untuk melindungi data pribadi dan transaksi keuangan para pemain. Selain itu, Detik4D juga bekerja sama dengan penyedia permainan terkemuka yang telah teruji dan terpercaya, sehingga para pemain dapat bermain dengan aman dan adil. Detik4D juga memiliki lisensi resmi dan diatur oleh otoritas perjudian yang terkemuka. Hal ini menjamin bahwa semua permainan yang ditawarkan adalah fair dan tidak ada kecurangan yang terjadi. Para pemain dapat bermain dengan tenang, mengetahui bahwa mereka berada di situs yang terpercaya dan terjamin. Jadi, jika Anda mencari situs slot 4D resmi dengan peluang menang besar dan pengalaman bermain yang mengasyikkan, Detik4D adalah pilihan yang tepat. Bergabunglah sekarang dan rasakan sendiri keseruan dan keuntungan yang ditawarkan oleh Detik4D.
    • Perjudian online telah menjadi tren yang populer di kalangan penggemar permainan kasino. Salah satu permainan yang paling diminati adalah mesin slot online. Mesin slot online menawarkan kesenangan dan kegembiraan yang tak tertandingi, serta peluang untuk memenangkan hadiah besar. Salah satu situs slot online resmi yang menarik perhatian banyak pemain adalah Tuyul Slot. Kenapa Memilih Tuyul Slot? Tuyul Slot adalah situs slot online resmi yang menawarkan berbagai keuntungan bagi para pemainnya. Berikut adalah beberapa alasan mengapa Anda harus memilih Tuyul Slot: 1. Keamanan dan Kepercayaan Tuyul Slot adalah situs slot online resmi yang terpercaya dan memiliki reputasi yang baik di kalangan pemain judi online. Situs ini menggunakan teknologi keamanan terkini untuk melindungi data pribadi dan transaksi keuangan pemain. Anda dapat bermain dengan tenang dan yakin bahwa informasi Anda aman. 2. Pilihan Permainan yang Beragam Tuyul Slot menawarkan berbagai macam permainan slot online yang menarik. Anda dapat memilih dari ratusan judul permainan yang berbeda, dengan tema dan fitur yang beragam. Setiap permainan memiliki tampilan grafis yang menarik dan suara yang menghibur, memberikan pengalaman bermain yang tak terlupakan. 3. Kemudahan Menang Salah satu keunggulan utama dari Tuyul Slot adalah kemudahan untuk memenangkan hadiah. Situs ini menyediakan mesin slot online dengan tingkat pengembalian yang tinggi, sehingga peluang Anda untuk memenangkan hadiah besar lebih tinggi. Selain itu, Tuyul Slot juga menawarkan berbagai bonus dan promosi menarik yang dapat meningkatkan peluang Anda untuk menang. Cara Memulai Bermain di Tuyul Slot Untuk memulai bermain di Tuyul Slot, Anda perlu mengikuti langkah-langkah berikut: 1. Daftar Akun Kunjungi situs Tuyul Slot dan klik tombol "Daftar" untuk membuat akun baru. Isi formulir pendaftaran dengan informasi pribadi yang valid dan lengkap. Pastikan untuk memberikan data yang akurat dan jaga kerahasiaan informasi Anda. 2. Deposit Dana Setelah mendaftar, Anda perlu melakukan deposit dana ke akun Anda. Tuyul Slot menyediakan berbagai metode pembayaran yang aman dan terpercaya. Pilih metode yang paling nyaman untuk Anda dan ikuti petunjuk untuk melakukan deposit. 3. Pilih Permainan Setelah memiliki dana di akun Anda, Anda dapat memilih permainan slot online yang ingin Anda mainkan. Telusuri koleksi permainan yang tersedia dan pilih yang paling menarik bagi Anda. Anda juga dapat mencoba permainan secara gratis sebelum memasang taruhan uang sungguhan. 4. Mulai Bermain Saat Anda sudah memilih permainan, klik tombol "Main" untuk memulai permainan. Anda dapat mengatur jumlah taruhan dan jumlah garis pembayaran sesuai dengan preferensi Anda. Setelah itu, tekan tombol "Putar" dan lihat apakah Anda beruntung untuk memenangkan hadiah. Promosi dan Bonus Tuyul Slot menawarkan berbagai promosi dan bonus menarik kepada para pemainnya. Beberapa jenis promosi yang tersedia termasuk bonus deposit, cashback, dan turnamen slot. Pastikan untuk memanfaatkan promosi ini untuk meningkatkan peluang Anda memenangkan hadiah besar. Kesimpulan Tuyul Slot adalah situs slot online resmi yang menawarkan pengalaman bermain yang seru dan peluang menang yang tinggi. Dengan keamanan dan kepercayaan yang terjamin, berbagai pilihan permainan yang menarik, serta bonus dan promosi yang menguntungkan, Tuyul Slot menjadi pilihan yang tepat bagi para penggemar mesin slot online. Segera daftar akun dan mulai bermain di Tuyul Slot untuk kesempatan memenangkan hadiah besar!
    • I have been having a problem with minecraft forge. Any version. Everytime I try to launch it it always comes back with error code 1. I have tried launching from curseforge, from the minecraft launcher. I have also tried resetting my computer to see if that would help. It works on my other computer but that one is too old to run it properly. I have tried with and without mods aswell. Fabric works, optifine works, and MultiMC works aswell but i want to use forge. If you can help with this issue please DM on discord my # is Haole_Dawg#6676
    • Add the latest.log (logs-folder) with sites like https://paste.ee/ and paste the link to it here  
    • I have no idea how a UI mod crashed a whole world but HUGE props to you man, just saved me +2 months of progress!  
  • Topics

×
×
  • Create New...

Important Information

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