Dampiir Posted April 8, 2020 Report Share Posted April 8, 2020 Hi I am trying to make tools and weapons that use the right mouse click instead of left click. I know right click is OnHeldInteractStart and step but how could I make it attack or mine blocks when the interact is held? Link to comment Share on other sites More sharing options...
Dampiir Posted April 8, 2020 Author Report Share Posted April 8, 2020 Ok so I tried using OnAttackStart and Step instead and it works but now I can't get it to stop the custom action. Just to clarify I am trying to add a stream of particles to the attack/mining action of my item. Also the custom action (particles) stops itself if used with OnInteractStart and Step but the returns are different for OnAttack so I am sure it's a simple fix to do with where/how the return is used I just can't figure it out. Here is my code: namespace ExampleMods { public class MinerMod : ModSystem { public override void Start(ICoreAPI api) { base.Start(api); api.RegisterItemClass("miner", typeof(MinerItem)); } } public class MinerItem : Item { //particles public static SimpleParticleProperties particles = new SimpleParticleProperties( 1, 1, ColorUtil.ToRgba(50, 220, 220, 220), new Vec3d(), new Vec3d(), new Vec3f(-0.25f, 0.1f, -0.25f), new Vec3f(0.25f, 0.1f, 0.25f), 1.5f, -0.075f, 0.25f, 0.25f, EnumParticleModel.Cube ); public override void OnHeldAttackStart(ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel, ref EnumHandHandling handling) { handling = EnumHandHandling.PreventDefaultAnimation; } public override bool OnHeldAttackStep(float secondsUsed, ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel) { if (byEntity.World is IClientWorldAccessor) { ModelTransform tf = new ModelTransform(); tf.EnsureDefaultValues(); tf.Origin.Set(0, -1, 0); tf.Rotation.Z = Math.Min(30, secondsUsed * 40); byEntity.Controls.UsingHeldItemTransformAfter = tf; if (secondsUsed > 0.6) { Vec3d pos = byEntity.Pos.XYZ.Add(0, byEntity.EyeHeight, 0) .Ahead(1f, byEntity.Pos.Pitch, byEntity.Pos.Yaw) ; Vec3f speedVec = new Vec3d(0, 0, 0).Ahead(5, byEntity.Pos.Pitch, byEntity.Pos.Yaw).ToVec3f(); particles.MinVelocity = speedVec; Random rand = new Random(); particles.Color = ColorUtil.ToRgba(255, 255, 100, 200); particles.MinPos = pos.AddCopy(-0.05, -0.05, -0.05); particles.AddPos.Set(0.1, 0.1, 0.1); particles.MinSize = 0.1F; particles.MaxSize = 0.5F; particles.SizeEvolve = new EvolvingNatFloat(EnumTransformFunction.LINEAR, 0); byEntity.World.SpawnParticles(particles); } } return true; } } } Link to comment Share on other sites More sharing options...
Recommended Posts