Jump to content

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


Recommended Posts

Posted

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.

Posted

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/

Posted

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

Posted

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.

Posted

In that case returning true in onBlockActivated should prevent the player from placing the block.

Author of PneumaticCraft, MineChess, Minesweeper Mod and Sokoban Mod. Visit www.minemaarten.com to take a look at them.

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.