Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.7.10] Changing block metadata on rightclick


Recommended Posts

I wanted to know if it is possible to use the onBlockActivated method to change the metadata of a custom block. This is the current contents of onBlockActivated of which I tried:

int test = w.getBlockMetadata(i, j, k);
	if (!w.isRemote){
		w.setBlockMetadataWithNotify(i, j, j, 1, 3);
	}
	return false;

 

Trying to use it to change the block's bound depending on metadata value. It's probably a simple issue to be honest xD

 

Member of Aerotech Networks, a Multi-Gaming server.

Also Currently porting the "Rise of the Automatons" minecraft mod

Link to post
Share on other sites

Ok, this works now. Here is a new question I have, how would I make my block's metadata change in a constant time. Like if I wanted it to change every 20 seconds. I already have an idea on how to make it stop at a set metadata as to not constantly increment, but I don't know how to make it change metadata at set times... What I mean is I don't want it to randomly change.

Member of Aerotech Networks, a Multi-Gaming server.

Also Currently porting the "Rise of the Automatons" minecraft mod

Link to post
Share on other sites

Probably a better way, but I would create a TileEntity for the block, and then in the updateEntity() method you can time it. updateEntity() is called every tick, and there are 20 ticks in a second.

Well, with the amount of blocks I plan to have this attibute, I don't think a tile entity would be a good option sadly :( . So anyone have an idea on how to make a block do what I want it to do, from my post above this replied post?

Member of Aerotech Networks, a Multi-Gaming server.

Also Currently porting the "Rise of the Automatons" minecraft mod

Link to post
Share on other sites

If you need something to happen every one of your block every 20 seconds you cannot get any more efficient than with a TileEntity. If you want this, it will have overhead, Whether you use a TileEntity or some custom built solution (which will most likely be less efficient than a TE).

Link to post
Share on other sites

Dang, because I was hoping I could make 100 blocks with this similar property. Welp, if needed I could either make less blocks, or just let it be random.

Member of Aerotech Networks, a Multi-Gaming server.

Also Currently porting the "Rise of the Automatons" minecraft mod

Link to post
Share on other sites

A TickHandler won't help you here.

Ok, so what's an answer to my other question? On how to increase rate of metadata change?

Member of Aerotech Networks, a Multi-Gaming server.

Also Currently porting the "Rise of the Automatons" minecraft mod

Link to post
Share on other sites

Well, just do it more often... In your TE onUpdate method.

Ok, but what if I wanted to make a sapling, or plant grow faster by default? Would I have to make a Tile Entity? Or would it be possible to do it as just a block. Would I use random.nextInt() with a greater range, equaling a larger set of numbers to increase chance of growth?

Member of Aerotech Networks, a Multi-Gaming server.

Also Currently porting the "Rise of the Automatons" minecraft mod

Link to post
Share on other sites

You can't increase the number of times the random tick happens. So if that is not often enough you need a TileEntity.

Well, I am happy.. Found out there was away to make it seem to be less random without tile entity... just used the world.scheduleBlockUpdate() method. Seems to work exactly how I wanted it. Set it to a 100 tick rate and it took 5 seconds to make the changes. :D

Member of Aerotech Networks, a Multi-Gaming server.

Also Currently porting the "Rise of the Automatons" minecraft mod

Link to post
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.

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



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.