Jump to content
  • Sign Up
Blue_3dx

Plugin example request

Recommended Posts

I need an example for held block click event like left/right clicking while holding a specific block does something for example sends a messages or runs a command

Share this post


Link to post
using System;

using MCGalaxy;
using MCGalaxy.Events;
using MCGalaxy.Events.PlayerEvents;

namespace MCGalaxy
{
	public class ClickHoldingBlockExample : Plugin
	{
		public override string name { get { return "ClickHoldingBlockExample"; } }
		public override string MCGalaxy_Version { get { return "1.9.5.1"; } }
		public override string creator { get { return "Rainb0wSkeppy"; } }
		
		public override void Load(bool startup)
		{
			OnPlayerClickEvent.Register(click, Priority.Normal);
		}
		
		public override void Unload(bool shutdown)
		{
			OnPlayerClickEvent.Unregister(click);
		}
		
		void click(Player p, MouseButton button, MouseAction action, ushort yaw, ushort pitch, byte entity, ushort x, ushort y, ushort z, TargetBlockFace face)
		{
			if (p.GetHeldBlock() != Block.Stone) return;
			if (action != MouseAction.Press) return;
			
			if (button == MouseButton.Left)
				p.Message("left click holding stone");
			else if (button == MouseButton.Right)
				p.Message("right click holding stone");
		}
	}
}

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...