Jump to content

[SOLVED] Cancelling a Player placing a block in the onBlockActivated() method?


Sirpwnsamin

Recommended Posts

Not through onBlockActivated, no.

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 suggest using events (i don't know which event, but you could search), check which block is about to be placed and then cancel if it's your block.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

Hi

 

Perhaps you could describe in a bit more detail what you're trying to do in terms of gameplay, because I'm a bit confused about exactly what you're trying to do

 

eg Once I've placed my Block of Repulsion, it won't let me add a second block of repulsion next to it unless I right-click on the ground instead of the block.

 

You might want to look at forge event onPlayerInteract(RIGHT_CLICK_BLOCK).

 

-TGG

Link to comment
Share on other sites

Hello,

 

Here is an example:

 

 

@ForgeSubscribe
public void onPlayerInteract(PlayerInteractEvent event)
{
	if (event.action == Action.RIGHT_CLICK_BLOCK)
	{
		if (event.entityPlayer.inventory.getCurrentItem().itemID == youritemid)
		{
			event.setCanceled(true);
		}
	}
}

 

 

Hope I helped!

 

ss7

You sir are a god damn hero.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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