Jump to content

Recommended Posts

Posted

I need this code to be around 6000 ticks plus a random 100 to 1000 ticks? Is there a way to do it or does it have to be a set amount.

    public int tickRate(World par1World)
    {
    	return 6000;
    }

Posted

Hi

 

From memory, tickRate does nothing unless you schedule the update yourself

i.e. you need to call scheduleBlockUpdate each time the block is ticked anyway?

 

If I've misunderstood your question, perhaps show us more of your code?

 

-TGG

 

 

 

Posted

I have set this up and it works. (I don't know if it is the right way though)

    public void onBlockAdded(World par1World, int par2, int par3, int par4)
    {
            par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, this.tickRate(par1World));
    }

    public int tickRate(World par1World)
    {
    	return 6000;
    }

    public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
    {
        par1World.setBlock(par2, par3, par4, Mod.Block.blockID);
                   
    }

 

Basically after about 5 minuets I am making my block change into a different block but I don't want it to be exactly 6000 ticks for each one. I have every thing setup and it works I just want to know if I can make the block change randomly after 6000 ticks.

Posted

I believe that every time you are placing a block, it is updating the tick rate for every block of that id in the world, which is why they are all the same, I could be wrong, but that's what it looks like to me, i'm thinking about how it could be fixed.

Posted

//declare this:
public int tickcount
//in the constructor:
this.setTickRandomly(true);
//and then add:
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
    {
if(tickcount < 50)
//Or a different value, you'll have to play around with it.
{
       tickcount++
}
else{
par1World.setBlock(par2, par3, par4, Mod.Block.blockID);
}
    }

That should be a lot more random than you have, still not sure if it's what you're looking for.

It's essentially the same as the code that farmland uses to decide if it is going to go back to being dirt, but with a counter in order to make it last longer.

Posted

There were errors when I added it this is what I have now with no errors but nothing is happening?

//declare this
public int tickcount;

//In the Constructor
        this.setTickRandomly(true);

//----
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
        {
	if(tickcount < 50)
	{
		tickcount++;  // <--- it says  insert ";" to complete BlockStatements
	}
	else
	{
		par1World.setBlock(par2, par3, par4, Mod.Block.blockID);
	}
    }

Posted

Just change the value of 50 to way lower, every number will give you on average 47 seconds, so setting 5 instead of 50 will change the block in roughly 4 minutes, but it could be way less or way more than that, depending on when the random ticks get assigned to the blocks. I'm pretty tired, don't know why I put 50 there, that would take something like an hour to change.

Posted

I worked! Thank you so much for sticking around and helping me! :):D

 

Just another thing when you said it could be way less if it was 7 could it still be only a few seconds and it would change?

Posted

Hi

 

Random ticks and scheduled ticks are not the same thing.  Random ticks occur randomly and are for things like leaves disappearing when not attached to a tree, farmland reverting to dirt, water turning to ice, etc.

 

Scheduled ticks are for things like water, buttons, etc.

 

I think your original code was pretty close already, i.e. you placed the block and 6000 ticks later it changes?

 

So what happened when you changed your 6000 to 6000 +Random.nextInt(100)?

 

-TGG

 

Posted

is your block class extending Block?

This code is working perfect for me:

public class ExampleBlock extends Block 
	{
		public ExampleBlock (int id, Material material) 
		{
			super(id, material);
		}
		@Override
		public void onBlockAdded(World world, int x, int y, int z) {
			world.scheduleBlockUpdate(x, y, z, this.blockID, this.tickRate(world));
		}
		@Override
	    public int tickRate(World par1World)
	    {
	    	return 6000;
	    }

	    public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
	    {
	        par1World.setBlock(par2, par3, par4, Block.dirt.blockID);
	                   
	    }
	}

Posted

Yeah but this way has a minimum value now, for instance:

public class ChemRack extends Block 
		{
			public ChemRack (int id, Material material) 
			{
				super(id, material);
			}

			@Override
			public void onBlockAdded(World world, int x, int y, int z) {

				world.scheduleBlockUpdate(x, y, z, this.blockID, this.tickRate(world));
			}

			@Override
		    public int tickRate(World par1World)
		    {
				Random random = new Random();
		    	return 4000+random.nextInt(2000);
		    }


		    public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
		    {
		        par1World.setBlock(par2, par3, par4, Block.dirt.blockID);
		    }
		}

has a minimum tick value of 4000, and a maximum of 6000, you can adjust to what you'd like.

I was under the assumption that the tick value of 6000 worked fine, and adding the random integer made it go haywire, which is why I had you try the other way. this is much more reliable.

Posted

public int tickRate(World par1World, Random random)
    {
    	return 6000 + random.nextInt(100);
    }

You want something like that?

 

Bad modder!  No cookie!  That function is no longer an override.

 

public int tickRate(World par1World)
    {
    	return 6000 + par1World.rand.nextInt(100);
    }

 

Magic!

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.

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

    • UPDATE: this seems to be an Arch-specific issue. Switching to Ubuntu server fixed EVERYTHING.
    • Yes, Attapoll offers a $20 Sign-up bonus for new users using a code (AOVCQ). Enter the Attapoll Referral Code “AOVCQ” and submit. Yes, Attapoll offers $20 Referral Code {AOVCQ} For New Customers. If you are who wish to join Attapoll, then you should use this exclusive Attapoll referral code $20 Signup Bonus Use this Code (AOVCQ) and get $20 Welcome Bonus. You can get a $20 Signup bonus use this referral code {AOVCQ}. You can get a $20 Attpoll Referral Code {AOVCQ}. This Attapoll $20 Referral code is specifically for existing customers and can be redeemed to receive a $20. Enter $20 Attapoll Referral Code {AOVCQ} at checkout. Enjoy $20Welcome Bonus. Use the best Attapoll referral code $20 (AOVCQ) to get up to $20 first time survey as a new user. Complete the survey and get $20 credited on your Attapoll account. Plus, refer your friend to earn 10% commission on their earning If you're on the hunt for a little extra cash or some cool rewards without too much hassle, you've landed in the right place. Today, we're diving into the world of Attapoll referral codes, a nifty way to boost your earnings while taking surveys. Use this Attapoll Referral Link or code {{AOVCQ}} to get a $20 sign up bonus.
    • Yes, Attapoll offers a $20 Sign-up bonus for new users using a code (AOVCQ). Enter the Attapoll Referral Code “AOVCQ” and submit. Yes, Attapoll offers $20 Referral Code {AOVCQ} For New Customers. If you are who wish to join Attapoll, then you should use this exclusive Attapoll referral code $20 Signup Bonus Use this Code (AOVCQ) and get $20 Welcome Bonus. You can get a $20 Signup bonus use this referral code {AOVCQ}. You can get a $20 Attpoll Referral Code {AOVCQ}. This Attapoll $20 Referral code is specifically for existing customers and can be redeemed to receive a $20. Enter $20 Attapoll Referral Code {AOVCQ} at checkout. Enjoy $20Welcome Bonus. Use the best Attapoll referral code $20 (AOVCQ) to get up to $20 first time survey as a new user. Complete the survey and get $20 credited on your Attapoll account. Plus, refer your friend to earn 10% commission on their earning If you're on the hunt for a little extra cash or some cool rewards without too much hassle, you've landed in the right place. Today, we're diving into the world of Attapoll referral codes, a nifty way to boost your earnings while taking surveys. Use this Attapoll Referral Link or code {{AOVCQ}} to get a $20 sign up bonus.
    • Yes, Attapoll offers a $20 Sign-up bonus for new users using a code (AOVCQ). Enter the Attapoll Referral Code “AOVCQ” and submit. Yes, Attapoll offers $20 Referral Code {AOVCQ} For New Customers. If you are who wish to join Attapoll, then you should use this exclusive Attapoll referral code $20 Signup Bonus Use this Code (AOVCQ) and get $20 Welcome Bonus. You can get a $20 Signup bonus use this referral code {AOVCQ}. You can get a $20 Attpoll Referral Code {AOVCQ}. This Attapoll $20 Referral code is specifically for existing customers and can be redeemed to receive a $20. Enter $20 Attapoll Referral Code {AOVCQ} at checkout. Enjoy $20Welcome Bonus. Use the best Attapoll referral code $20 (AOVCQ) to get up to $20 first time survey as a new user. Complete the survey and get $20 credited on your Attapoll account. Plus, refer your friend to earn 10% commission on their earning If you're on the hunt for a little extra cash or some cool rewards without too much hassle, you've landed in the right place. Today, we're diving into the world of Attapoll referral codes, a nifty way to boost your earnings while taking surveys. Use this Attapoll Referral Link or code {{AOVCQ}} to get a $20 sign up bonus.
    • Yes, Attapoll offers a $20 Sign-up bonus for new users using a code (AOVCQ). Enter the Attapoll Referral Code “AOVCQ” and submit. Yes, Attapoll offers $20 Referral Code {AOVCQ} For New Customers. If you are who wish to join Attapoll, then you should use this exclusive Attapoll referral code $20 Signup Bonus Use this Code (AOVCQ) and get $20 Welcome Bonus. You can get a $20 Signup bonus use this referral code {AOVCQ}. You can get a $20 Attpoll Referral Code {AOVCQ}. This Attapoll $20 Referral code is specifically for existing customers and can be redeemed to receive a $20. Enter $20 Attapoll Referral Code {AOVCQ} at checkout. Enjoy $20Welcome Bonus. Use the best Attapoll referral code $20 (AOVCQ) to get up to $20 first time survey as a new user. Complete the survey and get $20 credited on your Attapoll account. Plus, refer your friend to earn 10% commission on their earning If you're on the hunt for a little extra cash or some cool rewards without too much hassle, you've landed in the right place. Today, we're diving into the world of Attapoll referral codes, a nifty way to boost your earnings while taking surveys. Use this Attapoll Referral Link or code {{AOVCQ}} to get a $20 sign up bonus.
  • Topics

×
×
  • Create New...

Important Information

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