public override bool OnHeldAttackStep(float secondsPassed, ItemSlot slot, EntityAgent byEntity, BlockSelection blockSelection, EntitySelection entitySel) { if (byEntity.World.Side == EnumAppSide.Client) { IClientWorldAccessor world = byEntity.World as IClientWorldAccessor; ModelTransform tf = new ModelTransform(); tf.EnsureDefaultValues(); tf.Rotation.X = Math.Min(60, secondsPassed * 360); if (secondsPassed > 0.3) { tf.Translation.Z -= Math.Min(1.5f, 36f * (secondsPassed - 0.3f)); tf.Rotation.X -= Math.Max(-40, secondsPassed * 500); } byEntity.Controls.UsingHeldItemTransformAfter = tf; if (secondsPassed > 0.43f && byEntity.Attributes.GetInt("didattack") == 0) { world.TryAttackEntity(entitySel); byEntity.Attributes.SetInt("didattack", 1); world.ShakeCamera(0.25f); } } return(secondsPassed < 0.9f); }
public override bool OnHeldAttackStep(float secondsPassed, IItemSlot slot, IEntityAgent byEntity, BlockSelection blockSelection, EntitySelection entitySel) { float backwards = -Math.Min(0.35f, 2 * secondsPassed); float stab = Math.Min(1.2f, 20 * Math.Max(0, secondsPassed - 0.35f)); // + Math.Max(0, 5*(secondsPassed - 0.5f)); if (byEntity.World.Side == EnumAppSide.Client) { IClientWorldAccessor world = byEntity.World as IClientWorldAccessor; ModelTransform tf = new ModelTransform(); tf.EnsureDefaultValues(); float sum = stab + backwards; float ztranslation = Math.Min(0.2f, 1.5f * secondsPassed); float easeout = Math.Max(0, 10 * (secondsPassed - 1)); if (secondsPassed > 0.4f) { sum = Math.Max(0, sum - easeout); } ztranslation = Math.Max(0, ztranslation - easeout); tf.Translation.Set(sum * 0.8f, 2.5f * sum / 3, -ztranslation); tf.Rotation.Set(sum * 10, sum * 2, sum * 25); byEntity.Controls.UsingHeldItemTransformBefore = tf; if (stab > 1.15f && byEntity.Attributes.GetInt("didattack") == 0) { world.TryAttackEntity(entitySel); byEntity.Attributes.SetInt("didattack", 1); world.ShakeCamera(0.125f); } } return(secondsPassed < 1.2f); }